Ubuntu设置RS-232串口登陆终端(译文,节选)
原文地址:http://2stech.ca/index.php/linux/linuxtutotials/tutorials/207-ubuntu-serial-console-login
?
如果你有一臺(tái)服務(wù)器(不論大小),保留一個(gè)可以用來登陸系統(tǒng)的串口終端,通常來說是一件非常好的事情。這篇短文將展示如何配置服務(wù)器或PC上的串口,使其可以用作登陸終端。
前提
- 你已經(jīng)在BIOS中啟用了串口;
- 機(jī)器上第一個(gè)串口(在Linux系統(tǒng)中稱作/dev/ttyS0)使用的連接模式為“115200 8n1”,即:模特率115200,8個(gè)數(shù)據(jù)位,1個(gè)停止位,無奇偶校驗(yàn)。若串口不支持這種通訊方式,一般而言會(huì)使用“9600 8n1”模式;
- 你有足夠的能力及自信,去編輯和修改關(guān)鍵的系統(tǒng)文件(如/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 系統(tǒng)使用 Upstart 來啟動(dòng)。這就是我們要修改的第一個(gè)東西。
如果你查看 /etc/init 目錄下的文件,你會(huì)發(fā)現(xiàn)一些已有的終端服務(wù)配置文件,如 tty1.conf 等。很簡單,我們可以復(fù)制其中一個(gè)文件:
$ cp /etc/init/tty1.conf /etc/init/ttyS0.conf然后我們對(duì)新建的 ttyS0.conf 進(jìn)行修改:
將:
# 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
理論上講,文件的注釋部分是不需要修改的。但為了可讀性及后期維護(hù),我們?nèi)耘f修改它。?
當(dāng)你完成了以上修改, ttyS0.conf 文件應(yīng)該差不多是以下這個(gè)樣子:
# 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
此時(shí),你就可以開啟這個(gè)服務(wù)了:
$ sudo start ttyS0搞定!現(xiàn)在你就可以嘗試用串口進(jìn)行登陸了~
轉(zhuǎn)載于:https://www.cnblogs.com/Ricky-Gong/p/4437928.html
總結(jié)
以上是生活随笔為你收集整理的Ubuntu设置RS-232串口登陆终端(译文,节选)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 为app录制展示gif
- 下一篇: Android 程序打包及签名