AutoFsck - Technical Review
psusi at cfl.rr.com
Thu Aug 21 21:37:30 BST 2008
Krzysztof Lichota wrote:
> I don't quite follow you :) Can you be more explicit or give link to
> example code?
You chroot() to a subdirectory of the cwd, then you can chdir("..") to
escape. Once you chdir to the real root you chroot(".").
> In particular, what do you mean by "unlink all other files in /"?
> Unlink in the sense of "rm"?
Yes. The real root filesystem is a tmpfs populated by unpacking the
initramfs, so the last thing the init scripts do is unlink all of the
files, chroot, and exec the real init on the real filesystem, which then
frees up all of the memory used to hold the files from the initramfs
once the last reference is dropped.
> And the process you described is good for switching root to
> subdirectory. AFAIK this leaves old rootfs mounted. But how to apply
> it to switch from disk root to some other root _with unmounting
> previous root_?
Once you get back to the real real rootfs ( in ram ), place your
executables there, and exec them, there are no more references to files
in the on disk root so you just umount /root ( where the init scripts
mounted it initially ).
More information about the ubuntu-devel