HOWTO: Redirecting Linux console output over Serial Port on another machine
Purpose: In this post we will learn how we can redirect Linux console boot messages to a serial port on another computer. In one of my previous post, I had explained how to test serial ports under Linux. I highly recommend that you read it first before you read this post any further.
Requirements:
- Two computer with serial port: 1 running Linux (Machine 1) & another running Windows/Linux (Machine 2)
- A null modem serial cable: To connect both computers
- Software: minicom (on Linux) and Hyper-terminal (on Windows)
Background:
There are three parts to redirect the output on the serial port to another computer from the moment you start your Machine 1.
a) Outputting Grub screen
b) Outputting boot messages from moment you hit “Enter” at GRUB screen to moment you see the login console.
c) Outputting everything from login console onwards
Usually when you start your Linux machine you first see the BIOS information, then the GRUB screen, then booting happens and finally you see the login console. We will go step-by-step to see how to redirect each one of those starting from GRUB screen.
Usefulness:
This technique is useful in many circumstances like:
- Debugging Troubleshooting boot issues
- No output available on Monitor
- Network issues
- Copying and inspecting important boot messages produces by scripts
Step 1: Connect both the machines
The first step would be to connect both the machines via the null modem serial cable.
Machine 1 – Is the machine whose output we will redirect to Machine 2
Machine 2 – Is the machine on which we will see the output of Machine 1
Step 2: Launch a serial port terminal emulator
On Machine 2, launch a terminal emulator like minicom (if on Linux) or TeraTerm or HyperTerminal (if on Windows). For this post, I am assuming that we are using the minicom program on machine running Debian Linux. To launch minicom type in:
# minicom
Make sure that the serial port is configured with following settings:
+-----------------------------------------------------------------------+
| A - Serial Device : /dev/ttyS0 |
| B - Lockfile Location : /var/lock |
| C - Callin Program : |
| D - Callout Program : |
| E - Bps/Par/Bits : 38400 8N1 |
| F - Hardware Flow Control : Yes |
| G - Software Flow Control : No |
| |
| Change which setting? |
+-----------------------------------------------------------------------+
Note: You can do this by pressing Ctrl+A and then press ‘z’ key. And then press ‘o’ key and navigate to “Serial Port Setup” option.
Basically no matter what program you use, make sure you have following settings for your serial port configuration:
- Machine 1 – Port (Linux): ttyS0 or ttyS1 (depending on if your system as one or two serial ports)
- Machine 2 – Port (Windows/Linux): COM1/ttys0 or COM2/ttys1
- Bits per second: 38400
- Data bits: 8
- Parity: None
- Stop bits: 1
Step 3: Edit configuration files
All the following edits will me made on your Machine 1.
a) Redirecting GRUB screen
Go to Machine 1 and edit the file ‘/boot/grub/menu.lst’:
# nano /boot/grub/menu.lst
and add the following lines (in green) somewhere after password section:
## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line) and entries protected by the
# command 'lock'
# e.g. password topsecret
# password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret
serial --unit=0 --speed=38400 --word=8 --parity=no --stop=1
terminal --timeout=10 serial console
Save and Quit the file. Restart your Machine 1 and you should be able to see the following output on Machine 2:
Note: If you are using LILO as your bootloader then edit the lilo.conf file accordingly.
b) Redirecting boot process
Add the following lines to your kernel section in menu.lst file:
# nano /boot/grub/menu.lst
title Debian GNU/Linux, kernel 2.6.26-1-686
root (hd0,0)
kernel /boot/vmlinuz-2.6.26-1-686 root=/dev/hda1 ro vga=791 quiet console=tty0 console=ttyS0,38400n8
initrd /boot/initrd.img-2.6.26-1-686
Save and Quit the file. Restart your Machine 1 and you should be able to see the following output on Machine 2:
Note: First you will see the GRUB screen output just like we saw in Step 3 (a) and then you will see the boot process.
c) Redirecting the login console
Edit the file ‘/etc/inittab’ after making a backup copy of it:
# nano /etc/inittab
and add the following lines towards the end:
T0:23:respawn:/sbin/getty -L ttyS0 38400 vt100
T1:23:respawn:/sbin/getty -L ttyS1 38400 vt100
Save and Quit the file. Restart your Machine 1 and you should be able to see the following output on Machine 2 after the GRUB screen (step 3a) and boot process (step 3b) outputs:
Finally you can now log into your Machine 1 from Machine 2 over a serial connection just like you would SSH into any other Linux machine.
That’s it! Enjoy Serial Porting!




Free Email Subscription









June 9th, 2009 at 11:44 pm
[...] Learn how to redirect Linux console messages over Serial Ports on another machine. Linux Remote Desktop – Part 1: Connect remotely to GNOME session using VNCAnnouncement: Linux Remote Desktop SeriesHOWTO: Redirecting Linux console output over Serial Port on another machine Share and Enjoy: [...]
September 4th, 2009 at 3:39 am
Thanks very much, extremely useful, and surprisingly hard to find info.
Reply to this comment