Many companies nowadays use virtual machines as their servers.
Well what I’m gonna talk about today is how to export the serial console from your kvm-qemu virtual machine to a certain tty on your server.
It’s quite easy:
First thing is to start your vm with the -serial /dev/tty6 (or 7 or 8 or whatever) switch.
Ok so now we’ve got our server listening on the tty we specified for a serial connection. Now lets go to our virtual machine.
On our virtual machine, go to /boot/grub/menu.1st and add the following lines to the top of the file:
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
terminal --timeout=15 serial console
And change the kopt (in the same file) to:
# kopt=root=/dev/hda1 ro console=tty0 console=ttyS0,115200n8
Now go to your /etc/inittab and uncomment this line:
T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
Now we have to update grub:
update-grub
And reboot the virtual machine
Lets go back to our server:
try to enter the tty you specified, and there you go, your virtual machine is now exported to your servers tty.