嵌入式ARM Linux开发板自启动 免输入root用户名和密码

添加自动登录步骤:
1. 编译autologin.c程序
编译好的文件请看附件,如无必要,请跳过这一步,直接下载附件中的autologin镜像,然后进入第2步。
autologin.c文件内容
#include <unistd.h>
int main() {
        execlp(“login”,”login”,”-f”,”root”,0);
        return 0;
}

编译
# ${CROSS_COMPILE}gcc autologin.c -o autologin

2.拷贝文件
将生成的autologin拷贝至开发板/sbin目录下,如通过sd卡拷贝,并修改权限为可执行。
# cp /media/mmcblk0p1/autologin /sbin/
# chmod +x autologin

3. 修改/etc/inittab
#vi /etc/inittab
找到登录脚本所在行:
S:2345:respawn:/sbin/getty 115200 ttyO0

修改为:
S:2345:respawn:/sbin/getty -n -l /sbin/autologin 115200 ttyO0
保存退出

4. 同步文件系统并重启开发
# sync
重启开发板。

==========================

参考网页:
http://how-to.wikia.com/wiki/How … uto_login_at_bootup

参考源内容如下:

This howto show you howto get Linux to auto login in multi-user mode(non-GUI) at bootup.

Difficulty Operating Systems
med/hard linux
About:Ratings

RequirementsEdit

  • getty, or agetty; any getty that supports executing files (mingetty does not)
  • gcc: usually standard http://gcc.gnu.org
  • a boot disk or live cd is a good idea. If you make a mistake your computer may not boot up properly.

StepsEdit

You may not boot up if this isn’t done properly, and these steps may not be the same for your computer

  1. edit a file: for example ‘autologinz.c’, and add (zymos being the username)
    #include <unistd.h>
    int main() { execlp( “login”, “login”, “-f”, “zymos”, 0); }
  2. Compile the file by executing this command:
    gcc -o autologinz autologinz.c
  3. make sure autologinz is executable. For help See: Howto to change file permissions in unix
  4. chmod 755 autologinz
  5. as root, perform the next steps:
  6. copy the program you just created to /usr/local/sbin
  7. cp autologinz /usr/local/sbin
  8. Read NOTE! below before proceeding!
  9. edit ‘/etc/inittab’, and on line that looks similar to the following
    c1:2345:respawn:/sbin/agetty 38400 tty1 linux
    or
    1:2345:respawn:/sbin/mingetty tty1
  10. Replace that line with the following using the location of your executable
    c1:2345:respawn:/sbin/agetty -n -l /usr/local/sbin/autologinz 38400 tty1
    or
    1:2345:respawn:/sbin/agetty -n -l /usr/local/sbin/autologinz 38400 tty1
  11. reboot

NOTE! If your computer does not boot up properly use your boot disk to replace the line in ‘/etc/inittab’ to its original and read ‘man getty’

Print Friendly, PDF & Email
标签: , , ,

发表评论