串口配置

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.conf将console 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,这样的目的是允许root在ttyS0上登陆

修改/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


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值