AutoFsck - Technical Review
psusi at cfl.rr.com
Fri Aug 22 17:07:05 BST 2008
Krzysztof Lichota wrote:
> OK, but how to get to rootfs? In my /proc/mounts it is overmounted on
> "/", so it is not visible. I have tried to mount it in some other
> directory using "mount -t rootfs none /rootfs" but it fails.
You don't mount rootfs, it isn't an fs type. It simply is the root
filesystem that the kernel mounts as the root when it loads the
initramfs into it, and it is either a tmpfs or a ramfs.
> Do you mean I should modify init scripts to do stuff after chroot to
> disk root? I.e. in init on rootfs:
> mount /dev/sda /root
> chroot /root /sbin/init
> umount /root
> ...do my stuff...
No... the last thing the init scripts do is exec run-init, which does
the chroot+exec, so there is no returning from there.
I had thought that run-init just mounted the target root filesystem in
/root and then chrooted into it, but now that I check the source, it
looks like it does a move mount to overlay it on top of /, so given
that, it doesn't look like there is a way to escape back to it without
So it looks like what you need to do is mount a tmpfs and populate it
with the binaries ( and other things, like moving /proc, /sys, and /dev
there ) you need, then pivot_root with it and exec the new shell there,
which can unmount the old root and fsck it.
More information about the ubuntu-devel