run-init
is a binary executable, it lives in /usr/lib/klibc/bin/run-init and in your initramfs and is provided by the klibc-utils
package in Ubuntu. It isn't a script, so you cannot take a look inside directly, you can check out its source code via running apt source klibc-utils
or browsing the upstream repository at https://git.kernel.org/cgit/libs/klibc/klibc.git.
So the main function is in run-init.c , but it's just a wrapper for run_init
function, which lives here in runinitlib.c
run_init
does a lot of work:
- It jumps into the new root file system
- Checks that this is the new root file system
- Checks if it on initramfs
- Cleans all directory (why waste the RAM?)
- Mounts the new root file system
- and runs init in the new root file system
I believe, it would be very complicated to do all this work by a script, because of dependencies, but binary executable file can do it very ease.
/usr/lib/klibc/bin/run-init
. uselocate run-init
to find it in your system. – Mostafa Ahangarha Mar 13 '16 at 07:19panic
is next line after theexec run-init...
, is that mean the flow or control right will migrated to ${rootmnt}? If not so, we'll going to crash by nextpanic
? – naive231 Mar 14 '16 at 11:24