grub输出到串口、kernel信息输出到串口、XEN输出到串口

昨天周六专门跑到公司去好好整理了串口相关的配置。算是基本搞清楚了,所以再整理并记录一下。记得以前写过一点RHEL6中的串口配置,RHEL6串口配置

BIOS/GRUB/Kernel/XEN输出重定向到串口的配置:

  • BIOS输出重定向到串口
    这一功能需要主板支持,在BIOS中设置,比如我的设置为:

Server Management --> Console Redirection --> Console Redirection 设置为”Serial Port A”

  • GRUB输出重定向到串口(Edit /boot/grub/grub.conf)

serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1

terminal --timeout=5 console serial

grub引导过程中, 会将输出同时发送到终端屏幕和串口. grub引导过程中将在终端和连接到串口的超级终端上提示Press any key to continue, 每秒钟提示一次, 5, 可修改menu.lst文件terminal行中的--timeout=10改变提示次数, 在这一段时间内, 可以在终端的键盘, 或者连接到串口的超级终端中按任意键进入grub选择菜单. 如果5秒内没有在终端和连接串口的超级终端上按任意键, grub的选择菜单将出现在console, 如果希望默认情况下, grub选择菜单出现在串口上, 则可修改grub.confconsole serial修改为serial console.

  • kernel输出信息输出到串口(编辑 /boot/grub/grub.conf 有的为menu.lst)

增加kernel引导参数如下:

kernel  /boot/vmlinuz-2.6.32-29 root=/dev/hda1 ro console=ttyS0,115200n8 console=tty0

 kernel会将输出信息同时输出到串口(ttyS0COM1)和终端tty0

其中,“ttyS0”表示串口使用COM1“115200”表示波特率为115200bps“n”表示无校验位;“8”表示有8位数据位。

  • 允许从串口登陆linux  (如下配置可能会因发行版不同而有所区别)

确保/etc/securetty文件中有ttyS0,这样的目的是允许rootttyS0上登陆

修改/etc/inittab文件, 增加如下内容:

7:2345:respawn:/sbin/agetty -L 115200 ttyS0h

(当然得确保/sbin/agetty是存在的,另外,还有人推荐了mgetty,说它debug信息和log比较丰富,适合排错和测试。)

 

另外,XEN的串口配置稍微有点儿不同,附上我常用的一个配置吧:

default=0

timeout=5

splashimage=(hd0,2)/boot/grub/splash.xpm.gz

hiddenmenu

serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1

terminal --timeout=10 serial console

#0==========================================================================

title Xen-unstable (ia32e)

        root (hd0,0)

        kernel (hd0,0)/boot/xen.gz dom0_mem=1024M iommu=1,sharept loglvl=all guest_loglvl=all unrestricted_guest=1 console=com1 sync_console msi=1 conring_size=4M xsave hap_1gb=1

        module (hd0,0)/boot/vmlinuz-2.6-xen ro root=/dev/sda1 console=hvc0 earlyprintk=xen ignore_loglevel pci=assign-busses

        module (hd0,0)/boot/initrd-2.6-xen.img

 

其他:

户可以在内核命令行中同时设定多个终端,这样输出将会在所有的终端上显示,而当用户调用open()打开/dev/console时,最后一个终端将会返回作为当前值。例如:

console=ttyS0, 9600 console=tty0

定义了2个终端,而调用open()打开/dev/console时,将使用虚拟终端tty0。但是内核消息会在tty0 VGA虚拟终端和串口ttyS0上同时显示。

The Linux kernel is configured to select the console by passing it the console parameter. The console parameter can be given repeatedly, but the parameter can only be given once for each console technology. So console=tty0 console=lp0 console=ttyS0 is acceptable but console=ttyS0 console=ttyS1 will not work. When multiple consoles are listed output is sent to all consoles and input is taken from the last listed console. The last console is the one Linux uses as the /dev/console device

参考资料:

http://blog.csdn.net/defeattroy/article/details/5257323

http://wiki.xensource.com/xenwiki/XenSerialConsole

master

Stay hungry, stay foolish.

发表评论

邮箱地址不会被公开。 必填项已用*标注

*