Linux启动顺序和修改启动后执行程序

  1. Linux kernel mounts the root filesystem.
  2. The kernel starts the first user process /sbin/init provided by Busybox.
  3. /sbin/init reads /etc/inittab (From the SDK: linux/embedded_rootfs/etc-files/inittab).
  4. /etc/inittab starts the shell script /sbin/rc (From the SDK: linux/embedded_rootfs/etc-files/rc).
  5. /sbin/rc mounts the kernel pseudo filesystems /proc/dev/shm, and /dev/pts.
  6. /sbin/rc brings up the loopback network device with the IP address 127.0.0.1.
  7. /sbin/rc starts syslogd provided by Busybox.
  8. /sbin/rc starts telnetd provided by Busybox.
  9. /sbin/rc exits returning control in /sbin/init.
  10. /etc/inittab tells /sbin/init to spawn an interactive shell.
  11. 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.");

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值