Friday, 26 June 2015

Using the virtual serial port with KVM

So you've installed some linux virtual guests on your shiney new KVM hypervisor, virt-manager is great for managing them but needs X11. Given the guests are linux wouldn't it be nice to be able to get to the console using CLI? Here's how...

For RHEL 6 guests:

Add the following lines to /etc/grub.conf below the splashimage line
serial --unit=0
terminal --timeout=5 serial console
Then append console=ttyS0 to your kernel line
 kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/vg_rhel6-lv_root rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=uk LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 rd_LVM_LV=vg_rhel6/lv_swap crashkernel=auto rd_LVM_LV=vg_rhel6/lv_root rd_NO_DM rhgb quiet console=ttyS0

For RHEL 7 guests:

Add the following lines to /etc/default/grub
GRUB_TERMINAL="serial"GRUB_SERIAL_COMMAND="serial"
Amend the GRUB_CMDLINE_LINUX to include console=ttyS0
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos_tos7/swap rd.lvm.lv=centos_tos7/root rhgb quiet console=ttyS0"
Now regenerate the grub configuration
grub2-mkconfig -o /boot/grub2/grub.cfg

Reboot the guest and you're done.
Access your lovely new text console using virsh console <guest name>

No comments:

Post a Comment