- Linux kernel mounts the root filesystem.
- The kernel starts the first user process /sbin/init provided by Busybox.
- /sbin/init reads /etc/inittab (From the SDK: linux/embedded_rootfs/etc-files/inittab).
- /etc/inittab starts the shell script /sbin/rc (From the SDK: linux/embedded_rootfs/etc-files/rc).
- /sbin/rc mounts the kernel pseudo filesystems /proc, /dev/shm, and /dev/pts.
- /sbin/rc brings up the loopback network device with the IP address 127.0.0.1.
- /sbin/rc starts syslogd provided by Busybox.
- /sbin/rc starts telnetd provided by Busybox.
- /sbin/rc exits returning control in /sbin/init.
- /etc/inittab tells /sbin/init to spawn an interactive shell.
- The user interactive shell prompt appears.
修改rc文件即可设定linux自启动的程序,即启动linux后便会自己执行的程序或者shell脚步
static int noinline init_post(void)
{
free_initmem();
unlock_kernel();
mark_rodata_ro();
system_state = SYSTEM_RUNNING;
numa_default_policy();
if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
printk(KERN_WARNING "Warning: unable to open an initial console.\n");
(void) sys_dup(0);
(void) sys_dup(0);
if (ramdisk_execute_command) {
run_init_process(ramdisk_execute_command);
printk(KERN_WARNING "Failed to execute %s\n",
ramdisk_execute_command);
}
/*
* We try each of these until one succeeds.
*
* The Bourne shell can be used instead of init if we are
* trying to recover a really broken machine.
*/
if (execute_command) {
run_init_process(execute_command);
printk(KERN_WARNING "Failed to execute %s. Attempting "
"defaults...\n", execute_command);
}
run_init_process("/sbin/init");
run_init_process("/etc/init");
run_init_process("/bin/init");
run_init_process("/bin/sh");
panic("No init found. Try passing init= option to kernel.");
阅读(1031) | 评论(0) | 转发(0) |