歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Red hat Linux >> 如何在紅帽企業Linux下設置串口終端?

如何在紅帽企業Linux下設置串口終端?

日期:2017/3/2 16:58:25   编辑:Red hat 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 © Linux教程網 All Rights Reserved