Jan 032014
 

Finally I decide to turn on console on all my VMs so that I don’t have to rely on VNC for remote access whenever network is having problem – I’m trying to join corp network now and there are lots of network glitches during last week and I believe there will still be some in the coming week.

Actually it’s not that complicated, on CentOS (5 or 6) machines, add following line to /etc/inittab (do a dmesg | grep tty to make sure it is ttyS0 for you, but I believe they are all the same for kvm based VMs):
# for console
T0:2345:respawn:/sbin/agetty -h -L ttyS0 38400 vt100

then in /boot/grub/grub.conf:

  1. Comment out this line:
    splashimage=(hd0,0)/grub/splash.xpm.gz
  2. Add following lines after “hiddenmenu”, again make sure you are using the right tty device:
    serial --unit=0 --speed=38400 --word=8 --parity=no --stop=1
    terminal --timeout=10 serial console
  3. Append these to each line start with “kernel /vmlinux…”:
    console=tty0 console=ttyS0,38400n8

Reboot the machine, and attach to to console by “virsh console “, then you will get console for both book progress and normal login.

On Ubuntu 10.04 or 12.04 (these are two versions I’m currently using), create /etc/init/ttyS0.conf:
# ttyS0 - getty
#
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.

start on stopped rc or RUNLEVEL=[12345]
stop on runlevel [!12345]

respawn
exec /sbin/getty -L 115200 ttyS0 vt102

Then edit /etc/default/grub, change or add following lines:
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"

then “update-grub” to make it into real /boot/grub/grub.cfg (you can verify those console lines after running the command), then reboot, everything should be there.

  One Response to “Enable console on VMs”

  1. And this is something really need to be written down, to install Ubuntu in serial console:

    http://zensonic.dk/?p=264

Sorry, the comment form is closed at this time.