Re: klibc

Joshua Hudson
2006-06-09T23:13:15Z

On 6/9/06, H. Peter Anvin <hpa@zytor.com> wrote:
> Followup to: <bda6d13a0606091528h4e85265du8651818c73827b7d@mail.gmail.com>
> By author: "Joshua Hudson" <joshudson@gmail.com>
> 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
Should work if the following is true:
if pwd is /, mount / followed by ls . retunrs the contents of initramfs.