Debian with GRUB2 and serial connection

August 5th, 2009 | Tags:

Sometimes I’m using the serial connection to my server if anything goes wrong. It’s because I don’t have a monitor/TV attached to it.

I have little problems to set it up using Debian in GRUB2 after I upgraded to grub-pc

So here is a short way how to do it:

Edit file containing configuration in Debian: /etc/default/grub

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,9600n8"

# Uncomment to disable graphical terminal (grub-pc only)
GRUB_SERIAL_COMMAND="serial --speed=9600 --unit=0 --word=8 --parity=no --stop=1"

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux

Don’t forget to run update-grub after change.

VN:F [1.9.20_1166]
Rating: 9.0/10 (2 votes cast)
Debian with GRUB2 and serial connection, 9.0 out of 10 based on 2 ratings
  1. Zak B. Elep
    September 14th, 2009 at 12:21
    Reply | Quote | #1

    Hey, thanks for this bit. Came in handy while setting up a sid qemu. :)

  2. October 21st, 2009 at 00:45
    Reply | Quote | #2

    Hello there,

    I came across this post when I searched on how to set up output to go to the serial console when using grub2, and I found something missing in your post: in order to get a terminal on the remote machine, you need to add a line to /etc/inittab (described there).

    Anyway – have you managed to make grub2 actually show you the grub menu on the console? I can, for some reason, not get it to show anything but the output from the booting kernel and then the login-prompt and this slightly makes my reason for attaching a console to my machine go away as I might need to change boot parameters in case my remote machine misbehaves (my remote machine is ~100km away, so I can’t just go there and sort things there).

    I found numerous other posts like this one, but from people on other distributions, who actively mentions that they get the grub-menu on their console.. so. Your experience, please :)

    PS: I’m using Debian Testing (Squeeze)

  3. luciano
    December 11th, 2009 at 11:40
    Reply | Quote | #3

    In my Ubuntu 9.10 server installed on an industrial PC (PentiumIII) your suggestion works fine 100%. I can manage my server when i am at work via the local VGA console, and at home, via a Cisco 2500 terminal-server with the ttyS0 and a null-modem cable. I just modified the speed to 19200bps.
    Thank You

  4. January 2nd, 2010 at 17:09
    Reply | Quote | #4

    Don’t forget that you also need to add/uncomment an entry to your /etc/inittab file to create a serial console you can login to once the OS is booted.

    Something like this:
    T0:2345:respawn:/sbin/getty -L ttyS0 9600 vt100

    It is also worth saying that everything is more responsive if you increase the rate to 115200 rather than 9600.

  5. January 3rd, 2010 at 09:45
    Reply | Quote | #5

    115200 is much faster, but most devices like switches, routers and fw are using 9600. So that’s the reason why I’m using 9600 – it’s for compatibility :-)

    Good luck…

  6. Emmanuel Kasper
    March 10th, 2012 at 23:56
    Reply | Quote | #6

    You should use GRUB_CMDLINE_LINUX instead of GRUB_CMDLINE_LINUX_DEFAULT otherwise you’ll miss the console when you boot in rescue ( single user ) mode via a grub entry.