January 10, 2003
Serial console on Linux [ Software ]
Sometimes it'd be nice if computer UI's were good enough so that you could speak words of command: "Delete thy VGA display and write upon its buffer no more in this system!". Google helps a lot with this, but there's usually still some amount of grunt work involved.
Say you wanted to disable the VGA output of a Linux box and redirect all the output to a serial port. Not just run the VGA + serial simultaneously, but make as little output as possible come up on the VGA display. This is a wee bit more difficult than you might think at first.
First trick is to edit your /etc/lilo.conf (assuming you're using LILO instead of grub or some other bootloader) to include the following lines:
serial=0,9600n8 append="console=ttyS0,9600n8"
And then run /sbin/lilo to install the new bootblock. Great! This should direct the LILO output to the console and make Linux use the serial console.
Well, sort of. It'll make the boot sequence go to the serial output, but you'll still spawn a getty on the console, and if you're running XDM, you'll still see that.
So the next steps: (1) edit inittab to run a getty on the serial port, (2) disable XDM, and (3) rebuild your kernel if necessary.
(1) is straightforward, edit your /etc/inittab to include something like the following line:
T0:12345:respawn:/sbin/getty -L ttyS0 9600 vt100
Debian includes this, commented out by default, in their /etc/inittab. So uncomment it and restart init - a 'kill -HUP 1' should suffice - or wait until you reboot.
(2) is easy as well if you're using Debian or any other distro with SysV-style /etc/init.d scripts. Find the startup script for XDM (/etc/init.d/xdm in my case), and move it to DISABLED.xdm or something similar. That will prevent the /etc/rc*.d scripts from starting up the XDM services at boot.
(3) takes a little more work. You'll have to comment out the CONFIG_VT, CONFIG_VT_CONSOLE and CONFIG_VGA_CONSOLE and uncomment the CONFIG_SERIAL_CONSOLE. These are under the "Character Devices" section of menuconfig/xconfig, labeled as:
[ ] Virtual terminal (CONFIG_VT) [ ] Support for console on virtual terminal (CONFIG_VT_CONSOLE) ... [*] Support for console on serial port (CONFIG_SERIAL_CONSOLE)
After selecting these options and saving your config, you'll have to recompile and install your kernel. With Debian, I do the following:
chimera:/usr/src/linux# make-kpkg clean ... chimera:/usr/src/linux# make-kpkg -rev chimera.3 kernel_image ... chimera:/usr/src/linux# cd .. chimera:/usr/src# mv /lib/modules/2.4.18 /lib/modules/2.4.18-old chimera:/usr/src# dpkg -i kernel-image-2.4.18_chimera.3_i386.deb
And then it's automagically installed and it updates lilo, moves the modules into place, etc. Then reboot and check your VGA output.
The above steps get you to where LILO spits out its version number and tells you that it's loading Linux on the VGA display, and then stops. Your system's still going, but that's all that you'll see on the VGA display.
It'd likely take some source code modifications to LILO to get it to be more quiet than this, but it's a start.
Posted by edobbs at January 10, 2003 08:24 PM
Original content copyright ©1995-2006 Eric Dobbs, except where otherwise noted.
