05 August, 2009

Debian with GRUB2 and serial connection

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_DEFAULT=0
GRUB_TIMEOUT=1
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_TERMINAL=serial
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'
#GRUB_GFXMODE=640x480

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

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

7 comments :

  1. Zak B. Elep14/9/09 14:21

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

    ReplyDelete
  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)

    ReplyDelete
  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
    luciano

    ReplyDelete
  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.

    ReplyDelete
  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...

    ReplyDelete
  6. Emmanuel Kasper11/3/12 00:56

    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.

    ReplyDelete