免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1659 | 回复: 0
打印 上一主题 下一主题

Linux启动顺序和修改启动后执行程序 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-12-22 16:50 |只看该作者 |倒序浏览

  • 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)
    (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.");

    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/96265/showart_2128211.html
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP