{"id":1609,"date":"2014-01-03T14:37:46","date_gmt":"2014-01-03T21:37:46","guid":{"rendered":"http:\/\/xiehang.com\/blog\/?p=1609"},"modified":"2014-01-28T11:03:14","modified_gmt":"2014-01-28T18:03:14","slug":"enable-console-on-vms","status":"publish","type":"post","link":"https:\/\/xiehang.com\/blog\/2014\/01\/03\/enable-console-on-vms\/","title":{"rendered":"Enable console on VMs"},"content":{"rendered":"

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.<\/p>\n

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):
\n# for console
\nT0:2345:respawn:\/sbin\/agetty -h -L ttyS0 38400 vt100
\n<\/code><\/p>\n

then in \/boot\/grub\/grub.conf:<\/p>\n

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

    Reboot the machine, and attach to to console by “virsh console “, then you will get console for both book progress and normal login.<\/p>\n

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

    start on stopped rc or RUNLEVEL=[12345]
    \nstop on runlevel [!12345]<\/p>\n

    respawn
    \nexec \/sbin\/getty -L 115200 ttyS0 vt102<\/code><\/p>\n

    Then edit \/etc\/default\/grub, change or add following lines:
    \nGRUB_CMDLINE_LINUX=\"console=tty0 console=ttyS0,115200n8\"
    \nGRUB_TERMINAL=serial
    \nGRUB_SERIAL_COMMAND=\"serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1\"
    \n<\/code><\/p>\n

    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.<\/p>\n","protected":false},"excerpt":{"rendered":"

    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 […]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[465,131],"_links":{"self":[{"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/posts\/1609"}],"collection":[{"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/comments?post=1609"}],"version-history":[{"count":2,"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/posts\/1609\/revisions"}],"predecessor-version":[{"id":1641,"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/posts\/1609\/revisions\/1641"}],"wp:attachment":[{"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/media?parent=1609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/categories?post=1609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/tags?post=1609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}