Linux 開機到命令列模式並自動登入
From [url]http://blog.bestlong.idv.tw/2007/04/17/253[/url]有一些應用會希望電腦開機後自動登入並直接啟動指定的程式,例如:POS系統、機台設備的數控電腦等等。
針對這方面的需求,可以用 mingetty 這個套件來處理自動登入的需求。在 RedHat 與 Fedora Core 6 預設就是使用這個套件。以下就在 FC6 環境下操作:
1. 首先要讓 Linux 啟動後進入命令列模式(command-mode or console-mode)要做以下調整:
編輯 /etc/inittab 檔案,尋找一行設定內容為
id:?:initdefault:
其中的 ? 可能是 3 或 5 確定將 ? 修改成
id:3:initdefault:
存檔後直接 reboot 確認主控台是否開機後會跑到文字介面。 當然也可以跳過重開機部份直接進行下一步修改。
2. 讓 mingetty 自動登入
編輯 /etc/inittab 檔案,找到下列一段設定:[code]# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6[/code]請修改成[code]# Run gettys in standard runlevels
#1:2345:respawn:/sbin/mingetty tty1
1:2345:respawn:/sbin/mingetty --noclear --autologin user1 tty1
2:2345:respawn:/sbin/mingetty tty2
#3:2345:respawn:/sbin/mingetty tty3
#4:2345:respawn:/sbin/mingetty tty4
#5:2345:respawn:/sbin/mingetty tty5
#6:2345:respawn:/sbin/mingetty tty6[/code]然後重開機就可以看到,主控台開機完成後就會直接用 user1 帳號登入在 tty1 了,並且不會詢問密碼。 設定後開機出現下列訊息[code]Linux Kernel Config Problem with message "init: Id "1" respawning too fast: disabled for 5 minutes."[/code]遇到這個問題一般來說這常是你的 initrd 在 compile kernel 時沒有設定正確
包括要編出 initrd image 且在 kernel 中要 enable
但這些都設好以後還是有可能出問題
看到網路上有人說 devfs 和 mingetty 是有衝突的
I get the same behaviour when mingetty is configured to use tty*, but it
works fine with vc/*. In other words, edit /etc/inittab and change
2:23:respawn:/sbin/mingetty tty2
to
2:23:respawn:/sbin/mingetty vc/2 上面的問題是 /etc/inittab 中在啟動 mingetty 的時候失敗了
檢視 /var/log/messages 內容
發現 mingetty、/dev/tty1~6 not found 之類的錯誤訊息。
去重編 Linux Kernel 2.6.10,把 devfs 拿掉,只使用 udev 就成功了
頁:
[1]