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 GRUB as your bootloader.
First, edit /etc/inittab to set the default runlevel so that the system boots into text mode (Debian users, please see Recipe 17.4 for more information):
# The default runlevel. id:3:initdefault:
Then, open up a serial port to accept logins:
# 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. Then, 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
Then, 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 /boot/grub/grub.conf to tell the kernel to make ttyS0 (or whichever one you use) the default system console. Use the following example as a model, substituting your own filepaths, kernels, and titles:
#/boot/grub/grub.conf #Global section default 1 timeout 10 serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1 terminal --timeout=10 serial #boot stanzas title Debian-Sarge root (hd0,0) kernel /boot/vmlinuz-2.6.20-16 root=/dev/hda2 ro initrd /boot/initrd.img-2.6.20-16 title Debian-Sarge, serial root (hd0,0) kernel /boot/vmlinuz-2.6.20-16 root=/dev/hda2 ro console=ttyS0,9600n8 initrd /boot/initrd.img-2.6.20-16
Disable any splash images by deleting or commenting out any lines referring to them. 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.
GRUB counts from zero, so default=1
makes the second boot stanza the
default.
The serial=0, 9600n8
line
tells your server to be ready to accept control from the serial line,
and initializes the serial port.
console=ttyS0, 9600n8
on the
kernel line tells the kernel which serial port to use.
The --timeout=10
argument
tells GRUB to default to the first device listed in the terminal line
after 10 seconds.
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.
When you want to see boot messages on an attached monitor and the remote serial console, add the console option, like this:
#Global section ... terminal --timeout=10 serial console #boot stanzas ... kernel /boot/vmlinuz-2.6.11-ln.std root=/dev/hda2 ro console=tty0 console=ttyS0,9600n8
If you have an attached keyboard and monitor, and an attached remote serial console, you can strike a key on either one to make it the default. If you don't select one, it will default to the first device listed on the terminal 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.
man 1 startx
Remote Serial Console HOWTO:
Chapter 7, "Starting and Stopping Linux," in Linux Cookbook, by Carla Schroder (O'Reilly) tells how to customize runlevels
Chapter 12, "Managing the Bootloader and Multi-Booting," in Linux Cookbook
Recipe 15.2, "Using Both X Windows and Consoles," in Linux Cookbook