Getting a kvm serial console with grub2

I’ve a few kvm guest servers, which I’ve been accessing using vnc – but this is a bit of a pain (getting port forwarding setup etc). Host and guests run Debian Squeeze with Grub2 installed/in use.

So, here’s how to do the ‘virsh console ‘ thing …

  1. Edit /etc/default/grub, specify
    GRUB_TERMINAL=console 
    GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
    GRUB_CMDLINE_LINUX_DEFAULT=""
    GRUB_CMDLINE_LINUX="text console=tty0 console=ttyS0,115200n8"
  2. Run update-grub
  3. Edit /etc/inittab and enable ttyS0 for logins.
  4. Reboot
  5. ‘virsh console servername’ on the kvm host.

The libvirt config files I have already have the appropriate bits in them –

<serial type='pty'><target port='0'/></serial>
<console type='pty'><target type='serial' port='0'/></console>

Posted

in

by

Tags:

Comments

2 responses to “Getting a kvm serial console with grub2”

  1. Carlos Avatar
    Carlos


    3. Edit /etc/inittab and enable ttyS0 for logins.

    OR

    If you have a brand new ubuntu and lacks of inittab,

    – go to /etc/init/

    – copy tty1.conf to ttyS0.conf

    – edit it to start getty en ttyS0 dev instead of tty1

  2. Lirion Avatar
    Lirion

    On systemd systems, you may want to enable serial-getty@ttyS0.service. If you previously had the non-serial console getty@ttyS0.service ative, disable it – both being active would act like two ttys reacting to your input rendering a login via console basically impossible.

    The article is short and good (exactly what I like) – which is why I’m adding to it o/

Leave a Reply

Your email address will not be published. Required fields are marked *