shutdown busybox and start another PID1 process

Laurent Bercot ska-dietlibc at skarnet.org
Mon Aug 11 06:06:33 UTC 2014


On 2014-08-11 03:27, James Bowlin wrote:
> If someone had done a frugal install (copy the squashfs file to
> internal hd) or if they enable static root persistence (which
> opens a persistence file on the internal hd ) then it is
> impossible to cleanly umount the hd without doing a pivot_root
> first.  These problems are not just on ntfs.  There is a problem
> cleanly umounting any read-write file system that holds the
> squashfs file or the static root persistence file.

  Ah, that makes sense. Thanks for explaining.


> Before I can umount the ntfs (or other rw fs) I need to first
> umount the squashfs file and the static persistence file (if it
> is being used).  To do that I need to first umount the aufs which
> is the root file system.  Without the pivot_root, this is not
> possible.

  Isn't it possible to simply remount it read-only ? That's the
traditional way of fscking a rootfs, and it has always worked for
me - but maybe it's unapplicable to your situation, especially
with a HD install that users can modify.


>  Among other things, the pivot_root gives me access to
> /sys, /dev, and /proc even after I unmount the root file system.
> IMO even non-live systems would benefit from doing a pivot_root
> into a busybox system during shutdown.  You have access to a
> fully functional shell all the way up to the final "shutdown" or
> "reboot" command.

  /sys, /dev and /proc, as well as /tmp if it's a tmpfs, are also
available after you unmount all the rest and remount / read-only.
/bin/sh, or /bin/bash or whatever you want, is also available.
I don't think functionality is your argument here: you'll never
have *more* functionality than a full-fledged system that has
been live and made it all the way to your shutdown procedure.
  AIUI, your argument is reliability: by pivot_rooting on a known,
static, unmodifiable-by-the-user image, you have the guarantee
that you can perform clean operations even if the user has hosed
the root filesystem.


> The game I play with the Live system is to do a switch_root at
> the end of the /init script in the initrd and then do the
> opposite, a pivot_root on my way out. I start and end in a
> busybox environment.

  Hehe. I like to say that initrd/initramfs is useless, it adds
more complexity than it helps you. If you don't trust your rootfs'
usability, though, that's a good use case for it. (My stance is
valid for embedded systems, probably less so for desktops.)


> Many (at least a few) people use our LiveUSB or our frugal-install
> The easy/fast frugal install was the culmination of years of work
> (although I did not work continuously over those years, usually
> just 2-month or 3-month spurts).  I think the overall strategy
> and design were done in 2008 or 2009.  There was a lot of work
> and learning involved getting all the many pieces working.

  Come back to the candy store any time you want. Not only do we
have some yummy candy, but you may also have some brands to share
that we're not familar with!

-- 
  Laurent



More information about the busybox mailing list