Wednesday, 27 November 2013

Serial Console Mode Debugging with linux

If you want to redirect your kernel boot messages to serial console for debugging some issues in linux kernel booting, please follow the steps:

1. Connect a null modem cable from your test linux  machine (COM1/2) port to your serial port in laptop/desktop.

2. In Laptop with windows OS you can install putty/teraterm and set the necessary baud rate and other settings (9600 in my case)

3. In linux machine edit the grub.conf file 
    vi /boot/grub/grub.conf

4. Append the following lines after "hiddenmenu"
    serial --unit=0 --speed=9600
    terminal --timeout=10 console serial

5. comment out splashimage (as serial console will not have any graphics support)
    #splashimage=(hd0,0)/grub/splash.xpm.gz

6. Add "console=tty0 console=ttyS0,9600" to kernel command line of the kernel we want to debug

   Example: kernel /vmlinuz-2.6.32-42.0.10.ELsmp ro root=LABEL=/ console=tty0 console=ttyS0,9600
    
7. Edit file /etc/inittab
    append the line "1:23:respawn:/sbin/agetty ttyS0 9600 vt100" at the end

8. reboot

9. You will find press any key to continue message in your windows machine teraterm and all your log messages will be redirected to this console which you can save it for analysis.

Note: The above procedure was tested on centos 6.3 steps may vary for older kernels.