Linux Kernel and the init process
Solution 1:
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.");
Solution 2:
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.