17.2. Configuring a Headless Server with LILO

Your soon-to-be headless server now has all the pieces in place for running headless. Now, you need to know how to configure it to accept logins from a directly connected serial console, and you want to see a boot menu when you reboot from the console. You are using LILO as your bootloader.

First, edit /etc/inittab to set the default runlevel so that the system boots into a text runlevel. If the server does not have X Windows installed, skip this step:

	# The default runlevel.
	id:3:initdefault:

Then, open up a serial port to accept logins. This also happens in /etc/inittab:

	# Example how to put a getty on a serial line (for a terminal)
	#
	T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
	#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100

Uncomment the one you're going to connect to. (In this recipe, we'll use ttyS0.) The terminal emulation should already be vt100 or vt102; if it isn't, change it. Next, save your changes, and restart init:

	# init q

Fedora Linux users must take two extra steps. First edit /etc/sysconfig/init to disable ANSI colors, and disable the interactive startup with these lines:

	BOOTUP=serial
	PROMPT=no

Disable Kudzu because it will reset the serial port whenever it runs, and then you'll be disconnected. Edit /etc/sysconfig/kudzu:

	SAFE=yes

Now, edit the server bootloader to tell the kernel to make ttyS0 (or whichever one you use) the default serial console. Use the following example as a model, substituting your own filepaths, kernels, and labels:

	## /etc/lilo.conf
	#Global section
	
	boot=/dev/hda
	map=/boot/map
	install=menu
	prompt
	timeout=100
	serial=0,9600n8

	menu-title=" Webserver 1 "
	default="CentOS 5-serial"
	
	#boot stanzas
	

	image=/boot/vmlinuz-2.6.18.ELsmp
	         label="CentOS 5"
	         initrd=/boot/initrd-2.6.18.ELsmp.img
	         read-only
	         root=LABEL=/

	image=/boot/vmlinuz-2.6.18.EL
	         label="CentOS 5- serial"
	         initrd=/boot/initrd-vmlinuz-2.6.18.ELsmp.img
	         read-only
	         root=LABEL=/
	         append="console=ttyS0,9600n8"

Disable any splash images by deleting or commenting out the line referring to them. Do not enable a boot message because it won't work.

Then, write the changes to the master boot record (MBR):

	# /sbin/lilo -v

Reboot a few times to test. Don't disconnect the monitor and keyboard just yet—wait until you connect successfully from a remote serial console.

The Fedora /etc/sysconfig/init uses escape sequences to set colors, which can confuse your serial console, so it's best to disable colors entirely.

The serial=0,9600n8 line tells your server to be ready to accept control from serial line ttyS0, initializes the serial port at a speed of 9600 baud, no parity, 8 bits.

append="console=ttyS0,9600n8" tells the kernel which serial port to use.

If you have more than one serial port, how do you know which one is ttyS0, and which one is ttyS1? If your motherboard manual doesn't tell you, you'll just have to use trial and error.

Use this line when you want to see boot messages on an attached monitor and the remote serial console:

	append="console=tty0 console=ttyS0,9600n8"

The attached monitor will see only the boot menu, then will appear to hang until the login prompt comes up. The remote serial console will receive all boot messages, including output from the init system, and system log messages.

Remember that timeout is measured in tenths of second.

The install option has changed, starting with LILO version 22.3. It used to select the user interface from a file in /boot; now, the user interface is an additional menu option. Your choices are text, menu, and bmp. text is strictly command-line. menu is a text-based boot menu, plus a command-line option. bmp is a big old graphical screen, which you definitely don't want over a serial line.

Booting to text mode still gives you the option to run X Windows when you want; simply run the startx command on the server to start up X Windows. You won't see an X session over the serial line—this only makes sense when you want an X session on an attached monitor, or you are running remote X clients from the server.