Re: klibc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/9/06, Nix <[email protected]> wrote:
On Fri, 9 Jun 2006, Joshua Hudson whispered secretively:
> On 6/9/06, Nix <[email protected]> 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?

Once again. Loopback mount requires a clean unmount of root and
host filesystem. After remounting root read-only, host is still read-write
and cannot be remounted read-only.

It is necessary to provide access to the rootfs tree somewhere else
or use pivot_root, like the initrd solution below:

initrd: /linuxrc
#!/bin/sh
mount /dev/hda1 -o rw -t ntfs /host
mount /host/linux/root.img -o loop,ro -t ext3 /root
pivot_root /root /root/initrd
exec /initrd/bin/init

root:/etc/rc.d/rc.halt:
#!/bin/sh
pivot_root /initrd /initrd/root
cd /
exec /stop $RUNLEVEL

initrd:/stop
#!/bin/sh
kill -SIGUSR1 1
umount /root
umount /host
case $1 in
0) poweroff -f ;;
*) reboot -f ;;
esac


This requires static binaries of init, sh, mount, umount, an extant /etc, and a
few nodes in /dev.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux