In my last blog post I described how you can shut down your virtual machines with the virsh shutdown command under Debian and Ubuntu. Now I want to show you how virsh console can be used to access the serial console for login and watching the virtual machine’s shutdown and startup.
Step 1A: Preparing an Ubuntu Guest VM
- login on the ubuntu vm with ssh
- Copy tty1.conf to ttyS0.conf:
sudo cp /etc/init/tty1.conf /etc/init/ttyS0.conf
- open ttyS0 and change the last line to
exec /sbin/getty -8 115200 ttyS0 xterm
Step 1B: Preparing a Debian Guest VM
- login on the ubuntu VM with ssh
- open /etc/inittab
- uncomment the following line:
T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
Step 2: Make Grub output on ttyS0 (Debian & Ubuntu VM)
- open /etc/default/grub
- update GRUB_CMDLINE_LINUX:
- save & close the file and update grub with
- reboot the virtual machine
On the host you can now access the serial console with virsh console vm1.
To get back to the host use ctrl + ]. An opened session will not be closed so you have to logout explicitly (like if you were right in front of the machine).