Re: klibc

From: H. Peter Anvin
Date: Fri Jun 09 2006 - 18:47:42 EST


Followup to: <bda6d13a0606091528h4e85265du8651818c73827b7d@xxxxxxxxxxxxxx>
By author: "Joshua Hudson" <joshudson@xxxxxxxxx>
In newsgroup: linux.dev.kernel
>
> 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.

Another solution is to leave a process with its cwd parked in the
rootfs. Look at run_linuxrc() in usr/kinit/initrd.c of any klibc tree
to see how this can be used. (That is there to support old-style
/linuxrc, but should be applicable here, too.)

-hpa
-
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/