shutdown busybox and start another PID1 process

James B jamesbond3142 at gmail.com
Mon Aug 11 16:34:11 UTC 2014


Hi James (from another James).

On Mon, 11 Aug 2014 03:17:52 -0600
James Bowlin <bitjam at gmail.com> wrote:

> 
> There was a need to have static root persistence where the
> changes are saved directly in the root persistence file so I
> needed to bite the bullet and finally get clean umounts during
> shutdown.
> 
> Previously, filesystems were consistently reporting they were
> uncleanly mounted.  I wanted to do it all cleanly.  I tried like
> crazy to get remounting read-only to work but I just could not do
> it.  Maybe the problem was that I couldn't remount the rw file
> system under the aufs as ro (because the aufs was rw) and I
> couldn't remount the aufs as ro because its mount options are
> unconventional.

This is a solved problem. Fatdog64, an 64-bit offshot of Puppy Linux (disclaimer: I'm one of the maintainers), does exactly this - and have clean unmounts on common filesystems - fat32, ext2/3/4, ntfs (through ntfs-3g). The key is to remount ro the aufs layers; once made ro you can "unbind" them one by one (including the r/w layer). This ability to dynamically bind/unbind layers is one of the thing that makes me loves aufs so much - it is so much more versatile than any other layered filesystem out there *combined*. Get the ISO and take a look at its /etc/rc.d/rc.cleanup if you're interested.

> 
> Well busybox has all the tools I need.  The tmpfs gives me a place
> to stand so I can move the world^H^H aufs file system. It gives me
> a place where my tools and everything I need are off of the aufs.

Agreed, busybox is all you need.

> 
> I pivot onto a tmpfs that has the busybox stuff and very little
> else.  Root could easily erase it all.  Since it is tmpfs there
> is no need to umount it at all.  The point is to finish the
> shutdown from a tmpfs so I can cleanly umount the aufs and the
> filesystems under it including the file system on the host
> machine or on the LiveUSB.

My latest solution does pivot_root too for cleanliness reason, but it is actually unnecessary. You can still be on your original aufs root and take off the layer one by one - if you're careful - and have a clean unmount.

> 
> >   Hehe. I like to say that initrd/initramfs is useless, [...]
> 
> It is required for a live system.  

James, you won't convert Laurent :) I tried that before. 
I however is in the complete agreement with you. Initramfs is indispensable for this.
Anyway, to each his own.

---

If you really want to tell busybox init to quit - the simplest thing is to send SIGQUIT to it (kill -3 1). Once you do that, busybox init will execute all the ::shutdown scripts in /etc/inittab; and when done, it will exec to anything you put in ::restart. Whatever command you put in ::restart will run as pid 1 when all is said and done. This is however isn't useful for clean unmount because if you happen to use ntfs-3g, it will get killed too before it has the chance to unmount cleanly.

cheers!
James

-- 
James B <jamesbond3142 at gmail.com>


More information about the busybox mailing list