Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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.");
share|improve this answer

The program to run when kernel loading has completed can be given on the kernel boot command line using the init=/file/name argument.

If this option is not passed, the built-in default /sbin/init is used.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.