On Fri, 9 Jun 2006, Joshua Hudson whispered secretively:
> On 6/9/06, Nix <nix@xxxxxxxxxxxxx> wrote:
>> What happens if you do? I mean, it doesn't make even conceptual sense,
>> really. The rootfs is always there: that's its entire purpose.
>
> I just need it accessable somewhere else on the tree so that the system
> init runs from that rather than the root filesystem, and so can unmount
> root filesystem. Obvously, after a mount /, it is not.
You cannot unmount rootfs: it's the first filesystem mounted, the
ultimate parent of all attached mounts, the fallback used if you umount
everything else, and is explicitly checked for at mount and pivot_root
time.
You also don't often want to leave anything in it after you've booted:
unlike tmpfs, it's not swap-backed, so stuff in there stays in
nonswappable memory, pinned in the page cache. This is generally
undesirable. Yes, it stays around empty: but if you boot without an
initramfs, it stays around empty *in any case*: the kernel builds an
empty one and uses it automatically, then falls back to code which
mounts a root filesystem for you (code which HPA's klibc patch removes
in favour of doing everything it did from an initramfs).
The end of my initramfs script (busybox / uclibc-based) reads
# Unmount everything and switch root filesystems for good:
# exec the real init and begin the real boot process.
/bin/umount -l /proc
/bin/umount -l /sys
/bin/umount -l /dev
exec switch_root /new-root $init $INIT_ARGS
where switch_root is the aforementioned busybox `rm -rf everything on
this filesystem and mount --move us into the new root'. (At the time
it runs, it's PID 1 and there are no other non-kernel threads running:
it execs init.)
What are you trying to accomplish?