On Sat, Sep 17, 2011 at 6:27 PM, Dale <[email protected]> wrote: > Mark Knecht wrote: > I think there are only a few that has that flag, at least that I would put > in the init thingy anyway. Maybe this is something that the devs will work > on if it can be done. May be a big if there. > > That is the guide I am trying to go by but I think I am missing something. > This is the script they have posted: > > #!/bin/busybox sh > > # Mount the /proc and /sys filesystems. > mount -t proc none /proc > mount -t sysfs none /sys > > # Do your stuff here. > echo "This script mounts rootfs and boots it up, nothing more!" > > # Mount the root filesystem. > mount -o ro /dev/sda1 /mnt/root > > # Clean up. > umount /proc > umount /sys > > # Boot the real thing. > exec switch_root /mnt/root /sbin/init > > That doesn't really make much sense to me. First it mounts the stuff then > umounts it right after that. Huh? Is the relevant part the "mount -o ro > /dev/sda1 /mnt/root" ? Then the exec switch_root part after that? The rest > seems to cancel each other out. > > Looking forward to that light bulb moment here. ;-)
Here's how I read it. First, it mounts /proc and /sys, since just about anything is going to need at least one of those. Second, it mounts your (desired) / filesystem at /mnt/root. Third, it unmounts /proc and /sys. Fourth, it switches out / with the filesystem it already mounted at /mnt/root. This is similar (idential) to chroot. At the _same_ time, it launches your init script. Your init script launches and sees a / without a /proc or a /sys. The / it sees is what _was_ /mnt/root only moments before. The stuff that was originally at / is no longer accessible. (Which, incidentally, is why you unmount /proc and /sys; nothing would be able to get to those particular mounted filesystems, since everything else gets to see the world with /mnt/root/ as the /. Your init script (the one at /sbin/init), seeing itself in a fresh, needs-to-be-booted system, mounts /proc, /sys, etc...everything the init script is configured to do. -- :wq

