Is there any way to wait until the root file system is installed?

I have statically linked code (not a module) in the kernel that should start the kernel thread after installing the root file system. The problem is that I do not know how to do this without changing the kernel_namespace () function. I thought it was possible to do this through initcalls, but they are executed before the kernel takes care of rootfs. Does anyone know a better way to do this?

UPDATE [1]: @BenVoigit suggested the following solution in the comments: Looks like you should open / proc / mounts and poll_wait. See Source for `mounts_poll '

UPDATE [2]: I looked at the RSBAC patches, RSBAC modifies the prepare_namespace () function to perform some actions after mounting the file system. This seems to be the easiest way.

+3
source share
2 answers

Well, current Linux images are too large to fit the boot sector of a PC. Modern bootloaders, such as grub, mount a small file system in RAM to real.

To understand what is happening under the hood, you can open the disk image located under / boot. For example, in Ubuntu:

mkdir test
cd test
zcat /boot/initrd.img-2.6.35-24-generic > image.cpio
cpio -i < image.cpio
vim init

After all, this is just a bunch of shell scripts - simplicity is almost poetic.

0
source

You can use the rootfs_initcall () init call.

rootfs_initcall(func_init);
0
source

Source: https://habr.com/ru/post/1792900/


All Articles