如何在红帽企业Linux下设置串口终端?


在某些情况下,出于调试的目的需要给linux配置串口控制台,或者linux根本没有显卡,也需要配置串口终端。一个串口控制台将发送所有的终端显示到串口,而串口终端则可以实现通过串口登录到系统。你可以同时设置两个或者其中一个。

为了控制内核输出所有控制台消息到串口,你需要在时向内核传递参数console=ttyS0,这可以通过GRUB来实现,下面的例子会将控制台消息发送到tty0(显示器控制台)和ttyS0(串口1),发送到串口控制台的速度为115200,但是需要注意的是一种类型设备只能定义一个控制台,例如不能把消息同时发送到串口1和串口2,编辑/boot/grub/grub.conf,添加如下内容:


console=ttyS0,115200 console=tty0

例如:


# cat /boot/grub/grub.conf# grub.conf generated by anaconda## Note that you do not have to rerun grub after making changes to this file# NOTICE: You have a /boot partition. This means that# all kernel and initrd paths are relative to /boot/, eg.# root (hd0,0)# kernel /vmlinuz-version ro root=/dev/hda2# initrd /initrd-version.img#boot=/dev/hdadefault=0timeout=10splashimage=(hd0,0)/grub/splash.xpm.gztitle Red Hat Enterprise Linux AS (2.4.21-27.0.2.ELsmp) root (hd0,0) kernel /vmlinuz-2.4.21-27.0.2.ELsmp ro root=LABEL=/ console=ttyS0,115200 console=tty0 initrd /initrd-2.4.21-27.0.2.ELsmp.img

串口终端 为了设置一个串口终端,需要为串口衍生(spawn)一个agetty,在/etc/inittab添加如下内容: co:2345:respawn:/sbin/agetty ttyS0 115200 vt100 init q 例如:

# Run gettys in standard runlevels1:2345:respawn:/sbin/mingetty tty12:2345:respawn:/sbin/mingetty tty23:2345:respawn:/sbin/mingetty tty34:2345:respawn:/sbin/mingetty tty45:2345:respawn:/sbin/mingetty tty56:2345:respawn:/sbin/mingetty tty6co:2345:respawn:/sbin/agetty ttyS0 115200 vt100 init q

也可以在/etc/securetty文件中添加串口设置,这样才可以以root身份从串口登录,在该文件最后添加一行,内容为


ttyS0


(如果不添加此行,则登录时会不能输入密码。)

 

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3