2009年7月14日 星期二

Ubuntu Linux Box – Serial Console

Origin : http://www.debuntu.org/how-to-set-up-a-serial-console-on-debian
首先確認你自己的系統上面有沒有ttyS0

$ dmesg | grep tty
[    4.702353] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    4.702511] serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
[    4.703397] 00:0e: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    4.703687] 00:12: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A

這表示你的Serial Port可以衝到最高16500Bps的速率。當然,這前提是,你的box有顯示卡,或者,你可能已經正在用Serial Console,如果你只是先在別的環境下安裝系統,這指令可能沒啥幫助。

第一步驟,叫getty開始去監聽ttyS0,ubuntu新版作法是編輯/etc/event.d/ttyS0

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

start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5

stop on runlevel 0
stop on runlevel 1
stop on runlevel 6

respawn
exec /sbin/getty -L 115200 ttyS0 vt102



或者,你也可以偷抄襲tty0。



較舊的Debian要修改inittab




T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100



然後重起init



 



第二步驟,修改Grub啟動參數



首先讓grub認識ttyS0,加入下面介紹



# Enable console output via the serial port. unit 0 is /dev/ttyS0, unit 1 is /dev/ttyS1...
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
terminal --timeout=7 serial console


然後再核心啟動參數後面加上




console=ttyS0,115200n8 console=tty0



好啦,這樣就完成了。如果你發現你的老電腦居然沒有115200Bps HiSpeed,那,參數自己往下降到57600、38400試試看,重點是,Null Modem兩端協定要一樣,不然,亂碼看不懂。

沒有留言: