Help - Search - Members - Calendar
Full Version: HOWTO: setup remote serial console to display grub menu and boot process
The Planet Forums > System Administration > HOWTOs
revolution
hi,

this HOWTO will show you how to setup your redhat linux server (and probably a few others) to do the following:

* send the grub menu to the remote serial console (so you can select the kernel to boot from)

* send boot process info to the remote serial console (like what you see on your monitor when you boot up at home... you use linux at home, right?)

why does this matter? for me, this all equates to less stress during kernel upgrades (being able to see any problems, choose different kernels, change kernel boot parameters from the grub menu), and less stress when things go awry somewhere on a box and i have to use the master reboot switch and sit around twiddling my thumbs wondering if the system really is rebooting.

WARNING: if you aren't 100% sure of what you're doing, DO NOT do any of the following on a live/production server. in other words, if you are new to this stuff, only try this on your brand new box you just ordered just in case you mess it up so bad you have to get it re-imaged.

if you aren't sure what the remote console is or how to use it, please see this HOWTO: http://forum.ev1servers.net/showthread.php?t=52961

a thread discussing some uses for the remote console (and the people there probably could have made use of this tutorial) can be found here: http://forum.ev1servers.net/showthread.php?t=51199

using this tutorial requires grub to be installed as your server's bootloader (some basic instructions below). it's probably very possible to get the boot process info sent to the serial console even if you're using lilo, but i don't know how to do it with lilo and have no desire to google that info as i don't like or use lilo (maybe someone else will post info on how to do this with lilo).

this tutorial also makes a few extra assumptions, like that the serial port to use is ttyS0, but i doubt that won't be the case for anyone.

enjoy and let me know if you have any comments/additions/complaints.


on to the tutorial:

MAKE SURE GRUB IS YOUR BOOTLOADER

please note that what i have here does not replace outside knowledge of grub/bootloaders. again, if you aren't sure what you are doing, don't try any of this on a production server. i am far from a guru. don't put to much trust in my geek advice (my political views, however, should be taken very seriously =).

if you aren't sure if grub is your bootloader (default ev1 images at the time of writing have both grub and lilo installed [that is, the programs are present] but lilo is the bootloader installed on the MBR and so is the one in action). if you aren't sure which is on the MBR and you have grub installed, you can use this command (the # denotes the shell. don't type the #):

CODE
# grubby --bootloader-probe

that will output either "lilo" or "grub", telling you which is on the MBR.

so, this isn't a tutorial for installing grub, but i have found with fresh ev1 RHEL servers you can just run:

CODE
# grub-install /dev/device_name_of_first_disk

where device_name_of_first_disk is likely either hda or sda, depending on the type of drives you have. this will (hopefully) install grub on the MBR (and so lilo won't be there anymore). if you have just installed grub on the MBR and haven't rebooted yet, you should do that now just so you know that is working before you proceed with other changes (that is, so if there are problems you know at what point things got messed up).

SETUP GRUB AND THE BOOT PROCESS TO GO TO THE SERIAL CONSOLE

now, assuming you have grub installed, it's time to proceed with setting up the grub menu and the boot process to be sent to the serial console (i believe it will also still allow someone at the terminal to view the grub menu).

1) edit /etc/sysconfig/kudzu and make sure the value for SAFE is yes (change it if needed):

CODE
SAFE=yes

if you do not do this then the serial connection will be reset by kudzu during the boot process.

2) backup /boot/grub/grub.conf

3) edit /boot/grub/grub.conf and add the following two lines to the general config (not to any specific kernel):

CODE
serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1

terminal --timeout=5 console serial

now append this to any kernel lines who you want to see the output of in the console when you boot with those kernels:

CODE
console=ttyS0,9600n8 console=tty0

your resulting grub.conf might look something like this:

CODE
# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after making changes to this file

# NOTICE:  You have a /boot partition.  This means that

#          all kernel and initrd paths are relative to /boot/, eg.

#          root (hd0,0)

#          kernel /vmlinuz-version ro root=/dev/hda3

#          initrd /initrd-version.img

#boot=/dev/hda

default=0

timeout=10

fallback=2

splashimage=(hd0,0)/grub/splash.xpm.gz

serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1

terminal --timeout=5 console serial



title Red Hat Enterprise Linux ES (2.4.21-32.0.1.ELsmp)

       root (hd0,0)

       kernel /vmlinuz-2.4.21-32.0.1.ELsmp ro root=LABEL=/ console=ttyS0,9600n8 console=tty0

       initrd /initrd-2.4.21-32.0.1.ELsmp.img

title Red Hat Enterprise Linux ES (2.4.21-32.0.1.EL)

       root (hd0,0)

       kernel /vmlinuz-2.4.21-32.0.1.EL ro root=LABEL=/

       initrd /initrd-2.4.21-32.0.1.EL.img

title Red Hat Enterprise Linux ES (2.4.21-27.ELsmp)

       root (hd0,0)

       kernel /vmlinuz-2.4.21-27.ELsmp ro root=LABEL=/

       initrd /initrd-2.4.21-27.ELsmp.img

title Red Hat Enterprise Linux ES-up (2.4.21-27.EL)

       root (hd0,0)

       kernel /vmlinuz-2.4.21-27.EL ro root=LABEL=/

       initrd /initrd-2.4.21-27.EL.img

if you aren't sure about editing the grub.conf file, just note that if your system already booted fine from grub and you are just trying to get the serial console to show boot info, then you don't want to make any changes whatsoever to any of the vmlinuz or initrd filenames that are referenced. the only change you'll make to any of those kernels lines is to append the string i mentioned above to the end of the kernel line, as you can see in the above example.

note that in my example i've only changed one kernel to send boot info to the console. there's no reason for that other than a) i was lazy, b) i wanted to leave some untouched in case i messed things up adding this bit to the kernel line, and c) i don't boot from the other kernels. also, as you should be able to see the grub boot menu from the console now, you could likely boot your system fine even if you messed up the individual kernel configurations in grub.conf by using grub's handy ability to let you declare kernel boot parameters from the grub menu (for info on how to do that, seek out some grub tutorials).

that's it. now save your grub.conf, open a connection to the serial console (in a new window, if you want) and reboot. if all is goes well, you shouldn't be disconnected even because of a reboot. when the box starts back up you will see "press any key to continue" a few times. if you press a key right then you will get the grub menu. if you don't, a few seconds later (possibly after grub has shown the menu to the terminal?) your server will boot from the default kernel and you will start to see the boot info.

CREDITS

http://www.tldp.org/HOWTO/Remote-Serial-Co...ernel-grub.html

http://joyfire.net/HOWTO/Remote-Serial-Con...figure-rhl.html

http://publib.boulder.ibm.com/infocenter/p...m7il110219.html
rgesnot
Thanks a lot for your HowTo, It works fine.

IN ENGLISH :
* GRUB Manual
* GRUB homepage
* Grub wiki
* Booting with GRUB

IN FRENCH (en francais) :
GRUB: LES BASES POUR FEDORA
propcgamer
wow awsome job, worked great
sandy
Thanks very much for this, im sure it will come in handy!
revolution
you're very welcome.
AdamS
If you want to do this with the LILO boot loader, just do the following:

Do this at your own risk! Tested on my production box, works great!

Backup lilo.conf
CODE
cp /etc/lilo.conf /root/lilo.conf



Edit /etc/lilo.conf

Add this to the global section:
CODE
serial=0,9600n8


Add the following to the append line for each kernel image:
CODE
console=tty0 console=ttyS0,9600n8


Run "lilo" command to update MBR:
CODE
# lilo



Old lilo.conf may look like this:
CODE
prompt

timeout=50

default=2.4.21-15.0.3.E

boot=/dev/hda

map=/boot/map

install=/boot/boot.b

message=/boot/message



image=/boot/vmlinuz-2.4.21-15.0.3.EL

       label=2.4.21-15.0.3.E

       initrd=/boot/initrd-2.4.21-15.0.3.EL.img

       read-only

       append="root=/dev/hda3"





New one looks like this:
CODE
prompt

timeout=50

default=2.4.21-15.0.3.E

boot=/dev/hda

map=/boot/map

install=/boot/boot.b

message=/boot/message

serial=0,9600n8



image=/boot/vmlinuz-2.4.21-15.0.3.EL

       label=2.4.21-15.0.3.E

       initrd=/boot/initrd-2.4.21-15.0.3.EL.img

       read-only

       append="root=/dev/hda3 console=tty0 console=ttyS0,9600n8"



freddo
So AdamS,

if I use LILO, I only have to edit lilo.conf to be able to watch reboot over serial port?
REBIS
Nice post!
eth00
QUOTE(freddo)
So AdamS,

if I use LILO, I only have to edit lilo.conf to be able to watch reboot over serial port?


Yeah that should be all you have to do, aside from a kernel that supports it of course icon_smile.gif
freddo
Would a stock RHEL3 kernel be OK?
eth00
QUOTE(freddo)
Would a stock RHEL3 kernel be OK?


Yes it will
monkeyman
Thanks revolution,

Great tip and invaluable when I just updated my kernel.

Just 1 question.

Is it ok to leave the settings that have been changed permanantly or is there any reason it should be changed back?

Thanks
revolution
QUOTE(monkeyman)
Thanks revolution,

Great tip and invaluable when I just updated my kernel.

Just 1 question.

Is it ok to leave the settings that have been changed permanantly or is there any reason it should be changed back?

Thanks

you're welcome. as far as i know, it's okay to leave them changed permanently. if anyone feels or knows otherwise, i'd be curious to know why.

a big advantage of leaving them changed permanently is that it will come in handy during unplanned reboots.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.