码迷,mamicode.com
首页 > 系统相关 > 详细

Ubuntu设置RS-232串口登陆终端(译文,节选)

时间:2015-04-18 20:32:05      阅读:1306      评论:0      收藏:0      [点我收藏+]

标签:

原文地址:http://2stech.ca/index.php/linux/linuxtutotials/tutorials/207-ubuntu-serial-console-login

 

如果你有一台服务器(不论大小),保留一个可以用来登陆系统的串口终端,通常来说是一件非常好的事情。这篇短文将展示如何配置服务器或PC上的串口,使其可以用作登陆终端。

前提

  • 你已经在BIOS中启用了串口;
  • 机器上第一个串口(在Linux系统中称作/dev/ttyS0)使用的连接模式为“115200 8n1”,即:模特率115200,8个数据位,1个停止位,无奇偶校验。若串口不支持这种通讯方式,一般而言会使用“9600 8n1”模式;
  • 你有足够的能力及自信,去编辑和修改关键的系统文件(如/etc/inittab, /boot/grub/menu.lst等); 
  • You are using a serial (null modem) cable. It is also possible to use a USB to Serial adaptor, but the tty* must be changed to reflect your hardware.

配置终端登陆过程

较新版本的 Ubuntu 系统使用 Upstart 来启动。这就是我们要修改的第一个东西。

如果你查看 /etc/init 目录下的文件,你会发现一些已有的终端服务配置文件,如 tty1.conf 等。很简单,我们可以复制其中一个文件:

$ cp /etc/init/tty1.conf /etc/init/ttyS0.conf

然后我们对新建的 ttyS0.conf 进行修改:

将:

# tty1 - getty

改为:

# ttyS0 - getty

将:

# This service maintains a getty on tty1 from the point the system is

改为:

# This service maintains a getty on ttyS0 from the point the system is

将:

exec /sbin/getty -8 38400 tty1

改为:

exec /sbin/getty -L 115200 ttyS0 vt102

理论上讲,文件的注释部分是不需要修改的。但为了可读性及后期维护,我们仍旧修改它。 
当你完成了以上修改, ttyS0.conf 文件应该差不多是以下这个样子:

# ttyS0 - getty 

# This service maintains a getty on ttyS0 from the point the system is 
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345] 
stop on runlevel [!2345]

respawn 
exec /sbin/getty -L 115200 ttyS0 vt1022

此时,你就可以开启这个服务了:

$ sudo start ttyS0

搞定!现在你就可以尝试用串口进行登陆了~

Ubuntu设置RS-232串口登陆终端(译文,节选)

标签:

原文地址:http://www.cnblogs.com/Ricky-Gong/p/4437928.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!