国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
將LINUX的控制臺定向到串口終端

目的: 臺機已經(jīng)裝好Linux,顯示器有問題,平時一般都SSH控制,當(dāng)Linux網(wǎng)絡(luò)掛的時候,想通過串口來管理。


硬件:臺機自帶兩個串口(上面的是COM1)[under Windows] or ttyS0[under Linux)),筆記本T61p沒有串口,買了個USB轉(zhuǎn)串口(具體見下圖)。同時需要串口交叉線一根(NULL modem Cable),母對母(公的是針),都是凹口那種。


目標(biāo)機器:安裝的CentOS 5.2 Linux 內(nèi)核2.6.18-92.1.22.el52.6.18-92.1.22.el5xen

客戶端: Windows XP SP3 IBM OEM. 安裝USB轉(zhuǎn)串口驅(qū)動。


需要把輸出定向到串口,一般有下面幾處:

  1. BIOS中的設(shè)置

  2. GRUB設(shè)置

  3. /etc/inittab 設(shè)置

  4. /etc/securetty 設(shè)置


BIOS中的設(shè)置


BIOS設(shè)置的作用我沒嘗試過,如果是可以連BIOS設(shè)置都可以定向到串口,那個強大了。也不知道如何去掉機器需要連鍵盤的限制。沒拿出顯示器所以沒看我臺機的BIOS,不過這個功能一般只有服務(wù)器級別的機器有?!咀?/font>1】臺機一般沒有串口重定向功能。


GRUB設(shè)置

這里的配置是為了把grub菜單定向到串口,這樣你就可以在串口操作grub,選擇啟動項,使用single mode等等。

同時也要給kernel參數(shù)加上console選項。


[root@CentOS5 ~]# cat /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 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/vg00/lv_root

# initrd /initrd-version.img

#boot=/dev/hdb1

serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1

terminal --timeout=10 serial console

default=2

timeout=20

#splashimage=(hd0,0)/grub/splash.xpm.gz =>這些在console下會工作不正常,注釋掉。

#hiddenmenu

title CentOS (2.6.18-92.1.22.el5)

root (hd0,0)

kernel /vmlinuz-2.6.18-92.1.22.el5 ro root=/dev/vg00/lv_root rhgb quiet

initrd /initrd-2.6.18-92.1.22.el5.img

title CentOS Serial[ttyS0] - Console (2.6.18-92.1.22.el5)

root (hd0,0)

kernel /vmlinuz-2.6.18-92.1.22.el5 ro root=/dev/vg00/lv_root console=ttyS0,9600 console=tty0

initrd /initrd-2.6.18-92.1.22.el5.img

title CentOS Console - serial[ttyS0] (2.6.18-92.1.22.el5) [get more output in serial console]

root (hd0,0)

kernel /vmlinuz-2.6.18-92.1.22.el5 ro root=/dev/vg00/lv_root console=tty0 console=ttyS0,9600

initrd /initrd-2.6.18-92.1.22.el5.img

title CentOS Xen (2.6.18-92.1.22.el5xen)

root (hd0,0)

kernel /xen.gz-2.6.18-92.1.22.el5

module /vmlinuz-2.6.18-92.1.22.el5xen ro root=/dev/vg00/lv_root rhgb quiet xencons=off

module /initrd-2.6.18-92.1.22.el5xen.img

title CentOS Xen Serial[ttyS0] - Console (2.6.18-92.1.22.el5xen)

root (hd0,0)

kernel /xen.gz-2.6.18-92.1.22.el5

module /vmlinuz-2.6.18-92.1.22.el5xen ro root=/dev/vg00/lv_root xencons=off console=ttyS0,9600 console=tty0

module /initrd-2.6.18-92.1.22.el5xen.img

title CentOS Xen Console - serial[ttyS0] (2.6.18-92.1.22.el5xen)

root (hd0,0)

kernel /xen.gz-2.6.18-92.1.22.el5

module /vmlinuz-2.6.18-92.1.22.el5xen ro root=/dev/vg00/lv_root xencons=off console=tty0 console=ttyS0,9600

module /initrd-2.6.18-92.1.22.el5xen.img

title Other

rootnoverify (hd0,0)

chainloader +1


后面的console有順序關(guān)系,詳見下文【注2】,我常用串口所以console=tty0 console=ttyS0,9600這個順序的輸出信息比較多。


因為我的機器有xen的內(nèi)核,xen默認(rèn)情況下會把串口做為xencons,所以這里設(shè)置xencons=off.

When multiple consoles are listed output is sent to all consoles and input is taken from the last listed console. The last console is the one Linux uses as the /dev/console device.

/etc/inittab 設(shè)置

系統(tǒng)系統(tǒng)后,需要在串口上監(jiān)聽請求,所以要有個類似服務(wù)器的程序(agetty, mgetty etc)。

/etc/inittab中添加

s0:2345:respawn:/sbin/agetty -L -f /etc/issue.serial 9600 ttyS0 vt100

#s1:2345:respawn:/sbin/agetty -L -f /etc/issue.serial 9600 ttyS1 vt100

#S0:2345:respawn:/sbin/mgetty -r -x 9 ttyS0 ==> mgetty 用來調(diào)試比較好,log也豐富。

What is a getty?

A getty is is a program that opens a tty port, prompts for a login name, and runs the /bin/login command. It is normally invoked by init.

所以其他程序就不能再來占用ttyS0了,串口是獨占模式的吧。


vt100:

vt100 is the terminal emulation. You can use others, but VT100 is the most common or "standard". Another widely used termial type is VT102.

OK都可以了,可以重啟server了。這里如果想測試下串口線,推薦先在Linux啟動下mgetty,因為他的debug信息和log比較豐富,適合排錯和測試。

#mgetty –r –x 9 ttyS0

Log/var/log/mgetty*中。


/etc/securetty設(shè)置

因為一般我們都是使用root登陸串口來維護,所以需要設(shè)置root可以在COM1COM2登陸。

/etc/securetty中添加:

ttyS0

ttyS1


Windows客戶端連接可以用超級終端或者Putty。


注意啟動server的時候,putty就應(yīng)該去連接串口了,這樣才可以看到所有信息。

Press any key to continue.

Grub menu

Booting.


本來正常情況下,接下去kernelboot信息應(yīng)該也會打到串口的。但是沒有,確定是Xen內(nèi)核的關(guān)系?!咀?/font>3】好像有人已經(jīng)碰到這個問題了。

系統(tǒng)啟動起來后,過了init,agetty就起來了,這個時候就可以通過串口登陸了。(/etc/securetty中需要添加ttyS0)



后記:

在做這次實驗的時候開始心里很沒底,因為串口從來沒搞過。雖然編程時涉及過串口編程,但到我這邊已經(jīng)只是網(wǎng)絡(luò)編程了。買了一個USB轉(zhuǎn)串口接口,兩個串口交叉線。我想要NULL modem線,店主不知道(額…), 開始不工作時一度懷疑線有問題。


還有就是開始不理解串口工作原理,我知道串口是字符設(shè)備,有啥數(shù)據(jù)得當(dāng)時就去讀。曾經(jīng)我連了串口并開了Putty去連,界面上沒輸出。1)因為當(dāng)時就是沒數(shù)據(jù)。 2)是有時候終端需要按鍵來激活(比如按幾下回車)。


還有就是可能終端設(shè)置問題。這塊我現(xiàn)在還不太清楚。因為終端設(shè)置涉及到有些鍵盤操作,比如刪除。我好幾次發(fā)現(xiàn)?Backspace鍵沒反應(yīng)而重啟過好幾次機器。后來發(fā)現(xiàn)我的終端設(shè)置需要先<= = 左箭頭左移然后 delete。



我的主板說明書上接口圖:

【注1:

http://www.linux.org/docs/ldp/howto/Remote-Serial-Console-HOWTO/rhl-biosserial.html

C.2. Configure the BIOS to use the serial port

Many servers allow the BIOS to be configured from the serial port, especially on systems designed for rack mounting. At the moment few machines designed to be used as desktop systems allow the BIOS to be accessed from the serial port.

【注2:

http://tldp.org/HOWTO/Remote-Serial-Console-HOWTO/configure-kernel.html

Chapter 5. Configure Linux kernel

The Linux kernel is configured to select the console by passing it the console parameter. The console parameter can be given repeatedly, but the parameter can only be given once for each console technology. So console=tty0 console=lp0 console=ttyS0 is acceptable but console=ttyS0 console=ttyS1 will not work.

When multiple consoles are listed output is sent to all consoles and input is taken from the last listed console. The last console is the one Linux uses as the /dev/console device.

【注3:

https://vb.serverknecht.de/showthread.php?t=129174

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
生活服務(wù)
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服