Linux Kernel and the init process

bootlinux

How does the linux kernel know the location of the /sbin/init program during the boot process? Is "/sbin/init" hard coded into the linux kernel source code?

Best Answer

Yes, /sbin/init is hardcoded into the source. See the function init_post init/main.c:

    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. "
          "See Linux Documentation/init.txt for guidance.");
Related Topic