31
rated 0 times
[
31]
[
0]
/ answers: 1 / hits: 4217
/ 2 Years ago, fri, august 19, 2022, 12:40:16
Just a theoretical question...
But what would happen if init
(in /sbin/init
) would be removed?
More From » kernel
Just a theoretical question...
But what would happen if init
(in /sbin/init
) would be removed?
The boot loader will load the kernel, the kernel would attempt to run init, not find it and panic.
The way out of it is to reboot, edit the boot parameters, add init=/bin/bash
and boot that way. The kernel will use bash as init. This will give you a chance to run commands and fix the system.
Correction
Apparently the kernel (file init/main.c) does:
if (!try_to_run_init_process("/sbin/init") ||
!try_to_run_init_process("/etc/init") ||
!try_to_run_init_process("/bin/init") ||
!try_to_run_init_process("/bin/sh"))
return 0;
panic("No working init found. Try passing init= option to kernel. "
"See Linux Documentation/init.txt for guidance.");
So it would find /bin/sh (which is a link to dash) and that will give you a shell and a chance to fix it without using the init=/bin/bash
boot parameter.