Re: klibc



On 6/9/06, Nix <nix@xxxxxxxxxxxxx> wrote:
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?

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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: Fedora Core 3 Update: kernel-2.6.12-1.1372_FC3
    ... I was in the middle of reporting problems with 1371 when 1372 came ... it can't mount the root filesystem. ... Mounting root filesystem ...
    (Fedora)
  • Re: fsck at boot, skip a disk ?
    ... single user mode still mounts all local file systems. ... order to edit /etc/fstab you'll have to remount the root filesystem ... then you'll need to mount /usr too. ...
    (Fedora)
  • DHCP net boot fails on V440
    ... It's failing to mount the root filesystem via the downloaded inetboot ... 1000 Mbps full duplex link up ... Sun Fire V440, No Keyboard ...
    (SunManagers)
  • Re: panic[cpu1]/thread=140a000: vfs_mountroot: cannot mount root
    ... The system cannot mount the root filesystem, ... What's the partition layout? ... of volume manager on there and don't take that into account while ...
    (comp.unix.solaris)
  • Re: Base system package not selected
    ... The bugs are known upstream but are apparently currently ... for the rootfs in /proc/self/mounts, ... rootfs on / type rootfs ... the root filesystem is mounted both ...
    (alt.os.linux)