armlinux開發板用戶自動登錄

開發板:AM335
虛擬機:ubuntu 14.04
編譯器:gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf
開發板內核:linux 4.4.12

設置開發板自動登錄目前而言就兩種方法
1.修改/etc/inittab文件
2.systemd方法

1.要是文件系統有/etc/inittab文件的話就可以修改/etc/inittab文件
找到如下兩行代碼,並在其前面添加#,將這兩行代碼註釋掉,代碼如下:
O0:12345:respawn:/sbin/getty 115200 ttyO0
1:2345:respawn:/sbin/getty 38400 tty1
在文件最後添加如下代碼:
0:12345:respawn:/sbin/mingetty –autologin=root –noclear ttyO0

2.我開發板Am335使用的是systemd,systemd 不使用 /etc/inittab 文件。

root@am335x-evm:~# /sbin/agetty    

Usage:
 agetty [options] <line> [<baud_rate>,...] [<termtype>]
 agetty [options] <baud_rate>,... <line> [<termtype>]

Open a terminal and set its mode.

Options:
 -8, --8bits                assume 8-bit tty
 -a, --autologin <user>     login the specified user automatically
 -c, --noreset              do not reset control mode
 -E, --remote               use -r <hostname> for login(1)
 -f, --issue-file <file>    display issue file
 -h, --flow-control         enable hardware flow control
 -H, --host <hostname>      specify login host
 -i, --noissue              do not display issue file
 -I, --init-string <string> set init string
 -J  --noclear              do not clear the screen before prompt
 -l, --login-program <file> specify login program
 -L, --local-line[=<mode>]  control the local line flag
 -m, --extract-baud         extract baud rate during connect
 -n, --skip-login           do not prompt for login
 -N  --nonewline            do not print a newline before issue
 -o, --login-options <opts> options that are passed to login
 -p, --login-pause          wait for any key before the login
 -r, --chroot <dir>         change root to the directory
 -R, --hangup               do virtually hangup on the tty
 -s, --keep-baud            try to keep baud rate after break
 -t, --timeout <number>     login process timeout
 -U, --detect-case          detect uppercase terminal
 -w, --wait-cr              wait carriage-return
     --nohints              do not print hints
     --nohostname           no hostname at all will be shown
     --long-hostname        show full qualified hostname
     --erase-chars <string> additional backspace chars
     --kill-chars <string>  additional kill chars
     --chdir <directory>    chdir before the login
     --delay <number>       sleep seconds before prompt
     --nice <number>        run login with this priority
     --reload               reload prompts on running agetty instances
     --help                 display this help and exit
     --version              output version information and exit
For more details see agetty(8).

可以看到有個參數是可以設置自動登錄的 所以只要在對應的文件里加入這個參數就能自動登錄了
修改/etc/systemd/system/getty.target.wants/[email protected]文件
在裏面把ExecStart修改爲如下所示
ExecStart=-/sbin/agetty -8 -L %I 115200 $TERM –autologin root
然後重啓開發板就重啓就可以發現自動登錄了

Arago Project http://arago-project.org am335x-evm ttyS3

Arago 2016.05 am335x-evm ttyS3

am335x-evm login: root (automatic login)

Last login: Wed Jul 12 02:20:59 UTC 2017 on tty1
root@am335x-evm:~# 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章