现在的位置: 首页 > 综合 > 正文

通过串口连接linux配置过程

2012年02月08日 ⁄ 综合 ⁄ 共 2005字 ⁄ 字号 评论关闭
在虚拟机下测试
1、 修改文件/etc/inittab
编辑文件inittab,增加tty:2345:respawn:/sbin/agetty ttyS0 9600 vt100的内容:
# vi /etc/inittab
# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
tty:2345:respawn:/sbin/agetty ttyS0 9600 vt100
“tty”为改行ID,“2345”指改行的运行级别是2、3、4、5级;“respawn”是使命令退出后再执行一次,以便其他用户能够登录;“/sbin/agetty ttyS0 9600 vt100”表示具体的命令,即通过他来执行打开串口/dev/ttyS0(COM1),后面是波特率和终端模式
 
2、 修改/etc/securetty文件
编辑文件/etc/securetty,增加ttyS0的内容:
该文件是允许root身份登录的tty设备列表,这些设备由/bin/login程序读取,为了使用户能以root身份通过串口登录,需要在该文件中添加“ttyS0”,说明系统认为这里的COM1是安全的;
# vi /etc/securetty 
console
ttyS0
……
 
3、 修改/boot/grub/menu.lst文件或者修改/etc/grub.conf文件
修改/boot/grub/menu.lst 文件,在文件的kernel 对应行上添加 “console=ttyS0,9600 console=tty0“,要令它生效需要重启系统
# vi /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=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-164.el5)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.18-164.el5 ro root=LABEL=/ rhgb quiet crashkernel=128M@16M console=ttyS0,9600 console=tty0
        initrd /boot/initrd-2.6.18-164.el5.img
 
4.关闭两台虚拟机一台linxu,一台xp
分别在两台虚拟机上,添加串口设备,并设置。 编辑第一台虚拟机,添加一个Serial Port,选择use named pipe,然后输入管道名称: //./pipe/com_1,然后下面选择this end is the server.和the other end is an application,把Yield CPU on poll勾上就可以了。 第二台虚拟机同上,尤其管道名称要一样,下面选择this end is the client.其他一样

5.安装设置Named Pipe TCP Proxy软件
在主机上安装设置Named Pipe TCP Proxy 打开Named Pipe TCP Proxy,选择Edit→New,然后设置好named pipe名称和端口号 pipe设置为: //./pipe/com_1(和vmare中名称一样) port设置为:2001(随机) , 其它默认。

6.测试
在xp虚拟机上用putty选择com1连接,波特率9600,连接成功,登录系统

 

抱歉!评论已关闭.