1概述
在单板测试和系统日常使用过程中,偶尔会遇到Linux内核Panic、Oops或硬件产生MCE等严重错误。而在屏幕或KVM的打印信息显示内容有限,导致部分内容无法看到。
本文主要介绍Linux系统串口重定向设置及内核打印信息的获取和保存,以全面记录内核故障信息。
2Redhat串口重定向设置
主要关注RedhatLinux操作系统设置串口重定向的具体操作上,适应Redhat以下版本:
lRedhat Enterprise Linux 4
lRedhat Enterprise Linux 5
lRedhat Enterprise Linux 6
注:Redhat Enterprise Linux 7版本请参考下面的2.3章节
2.1需要修改的文件
RedhatLinux 4/5版本的串口重定向设置主要涉及到以下三个文件的修改:
l/boot/grub/menu.lst
l/etc/inittab
l/etc/securetty
RedhatLinux 6版本的串口重定向设置只涉及到如下一个文件的修改:
l/boot/grub/menu.lst
注:
因RedhatLinux 6串口配置只涉及一个文件的修改,所以只需参考如下2.2.1和2.2.2的配置即可。
2.2串口重定向设置
2.2.1GRUB配置
n修改描述
配置GRUB以使用串口。注释splashimage配置项,增加serial、terminal如下两行配置项:
serial
--unit=0 --speed=115200
terminal
--timeout=15 serial console
n修改文件
/boot/grub/menu.lst
n修改样例
注:以下配置文件样例不是最终完整配置样例。
# grub.conf
generated by anaconda
#
# Note that you do
not have to rerun grub after making changes to this file
# NOTICE:You do not have a /boot partition.This means that
#all kernel and initrd paths are
relative to /, eg.
#root (hd0,0)
#kernel /boot/vmlinuz-version ro
root=/dev/sda1
#initrd /boot/initrd-version.img
#boot=/dev/sda
default=0
timeout=5
#splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
serial
--unit=0 --speed=115200
terminal
--timeout=15 serial console
title Red Hat
Enterprise Linux Server (2.6.18-8.el5xen)
root (hd0,0)
kernel /boot/xen.gz-2.6.18-8.el5
module /boot/vmlinuz-2.6.18-8.el5xen
ro root=LABEL=/ rhgb quiet
module /boot/initrd-2.6.18-8.el5xen.img
说明:
(1)灰色表示注释掉内容;
(2)蓝色表示增加内容;
(3)红色表示修改内容;
以下类同。
2.2.2内核配置
修改描述
配置kernel行,增加如下参数,以此来启用系统的第一个串口做为串行控制台:
console=tty0 console=ttyS0,115200n8
修改文件
/boot/grub/menu.lst
修改样例
# grub.conf
generated by anaconda
#
# Note that you do
not have to rerun grub after making changes to this file
# NOTICE:You do not have a /boot partition.This means that
#all kernel and initrd paths are
relative to /, eg.
#root (hd0,0)
#kernel /boot/vmlinuz-version ro
root=/dev/sda1
#initrd /boot/initrd-version.img
#boot=/dev/sda
default=0
timeout=10
#splashimage=(hd0,0)/boot/grub/splash.xpm.gz
serial
--unit=0 --speed=115200
terminal
--timeout=15 serial console
title Red Hat
Enterprise Linux Server(2.6.18-92.el5)
root (hd0,0)
kernel /boo