原始文件出處
LDP: Linux Remote Serial Console HOWTO (英文)
http://www.tldp.org/HOWTO/Remote-Serial-Console-HOWTO/
測試環境:
OS -- Red Hat Linux 9, Fedora Core 2
boot loader -- GRUB
設定鮑率為 9600, 資料位元 8, 同位檢查 n, 停止位元 1
修改步驟:
 - 修改 GRUB:
- GRUB 全域參數
 bash# vi /etc/grub.conf 新增下面二行以設定 serial console 為 9600/8/n/1, 以及 10 秒等待時間.
 serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1
 terminal --timeout=10 -dumb serial console
 
 
- 增加一個單人模式選項到 GRUB 選單
 title Red Hat Linux (2.4.9-21) single user mode
 lock
 root (hd0,0)
 kernel /vmlinuz-2.4.9-21 ro root=/dev/hda6 s
 initrd /initrd-2.4.9-21.img
 
- 修改每個 kernel 項目參數 , 加入紅色字部分
 title Red Hat Linux (2.4.9-21)
 root (hd0,0)
 kernel /vmlinuz-2.4.9-21 ro root=/dev/hda6 console=tty0 console=ttyS0,9600n8
 initrd /initrd-2.4.9-21.img
 
 
- 安裝 mgetty
- 系統已安裝的 mingetty 不支援 serial console.
 請取得 mgetty 並安裝.
 如: mgetty-1.1.30-2.i386.rpm
 rpm -ivh mgetty-1.1.30-2.i386.rpm 
- 在 /etc/mgetty+sendfax/mgetty.config 如下設定 ttyS0
 bash# vi /etc/mgetty+sendfax/mgetty.config
 
 port ttyS0
 speed 9600
 direct yes
 data-only yes
 toggle-dtr yes
 need-dsr yes
 port-owner root
 port-group root
 port-mode 600
 login-prompt @ \P login:\040
 login-time 60
 term vt102
 
- /etc/inittab 設定
- 設定 mgetty 為 ttyS 設備, 在最下面增加一行
 bash# vi /etc/inittab
 
 co:2345:respawn:/sbin/mgetty ttyS
- 在 /etc/inittab 改變預設登入的 run level 為文字模式 ( run level 3)
 找到
 id:5:initdefault: 改為
 id:3:initdefault: 
- 在 /etc/inittab 移除不用的 mingetty 項目
 1:2345:respawn:/sbin/mingetty tty1
 # Additional virtual terminals are not used
 2:2345:off:/sbin/mingetty tty2
 3:2345:off:/sbin/mingetty tty3
 4:2345:off:/sbin/mingetty tty4
 5:2345:off:/sbin/mingetty tty5
 6:2345:off:/sbin/mingetty tty6
 
- 存檔離開, 重新啟動 init
 bash# telinit q 
- 編輯 /etc/securetty 以允許 root 由 serial console 登入
 在 /etc/securetty 加入下面一行
 ttyS0 
- 移除現有的 console 設定
 bash# rm -f /etc/ioctl.save 
- 改變 /dev/systty 的裝置設定
 bash# cd /etc/makedev.d
 bash# fgrep systty *
 linux-2.4.x:l systty tty0
 bash# vi linux-2.4.x
 找到
 l systty tty0 改為l systty ttyS0 存檔, 重新建立 /dev/systty
 bash# cd /dev
 bash# rm systty
 bash# ./MAKEDEV systty
 
- PAM 認證設定
 bash# vi /etc/security/console.perms 增加下面一行
 <sconsole>=ttyS0 然後把 console 的項目改為 sconsole
 <sconsole>  0660 <floppy>     0660 root.floppy
 <sconsole>  0600 <sound>      0600 root
 <sconsole>  0600 <cdrom>      0660 root.disk
 <sconsole>  0600 <pilot>      0660 root.uucp
 <sconsole>  0600 <jaz>        0660 root.disk
 <sconsole>  0600 <zip>        0660 root.disk
 <sconsole>  0600 <ls120>      0660 root.disk
 <sconsole>  0600 <scanner>    0600 root
 <sconsole>  0600 <camera>     0600 root
 <sconsole>  0600 <memstick>   0600 root
 <sconsole>  0600 <flash>      0600 root
 <sconsole>  0600 <mainboard>  0600 root
 <sconsole>  0600 <rio500>     0600 root
- Red Hat Linux 的設定
 
- bash# vi /etc/sysconfig/init 改為
 - BOOTUP=serial
 PROMPT=no
 
- bash# vi /etc/sysconfig/kudzu 改為
 - SAFE=yes 
- 現在可以重開機並測試你的 seial console
LILO 的修改:LILO 全域參數設定範例:
serial=0,9600n8
timeout=100
restricted
password=PASSWORDThe password should be good, as it can be used to gain root access.
LILO 的 password 是以 plain text 存在設定檔, 所以不要跟你其他的密碼相同. 設定檔的權限應該設定為只能讓 root 可以讀取 /etc/lilo.conf. 設定方式如下:
bash# chmod u=rw,go= /etc/lilo.confLILO 有顯示開機訊息的功能,但不能在 serial console 顯示,請刪除像下面此行的設定:
message=/boot/message至此 LILO 已經設定好使用 serial console.
對於 /etc/lilo.conf 中的每個 image 項目加入此行:
append="console=tty0 console=ttyS0,9600n8"若已經有 append 敘述. 例如
append="mem=1024M"可改成如下敘述以傳送所有的參數:
append="mem=1024M console=tty0 console=ttyS0,9600n8"這樣就完成 LILO 的設定.
現在用 lilo 指令安裝新的 boot record 到磁碟上:
bash# chown root:root /etc/lilo.conf
bash# chmod u=rw,g=,o= /etc/lilo.conf
bash# lilo
Added linux *現在可以重開機並測試你的 serial console.