do stuff after shutdown

Michael Conrad mconrad at intellitree.com
Thu Feb 23 22:24:37 UTC 2012


On 2/23/2012 4:52 PM, Michael Di Domenico wrote:
> I have a busybox system booting over pxe, it does some stuff and then
> eventually boots up my main linux distro.  my question is; when i'm
> done with my main linux distro, is it possible to run commands back in
> the busybox shell after the switchroot completes/returns?
>
> does it move stuff back and let you continue to run a command or two,
> or is the environment trashed requiring a reset of the box.  my
> inclination from the code is that it's trashed, but i just want to
> make sure

If the init process exits, the kernel panics.  Therefore no normal 
distro will ever have an init that returns to its caller.  (also, if you 
didn't exec into the new init, then it wouldn't be process 0, and could 
cause you problems)

switchroot allows you to free up the initramfs, but you don't have to 
use it.  You could actually run your own init process and chroot your 
distro's startup scripts (effectively chrooting everything else in 
userspace), and play games with symlinks to /lib/modules.... but at 
shutdown your distro will still call reboot() at the end which go 
straight to the kernel, and not to any script outside the chroot.

Most likely you want to alter the shutdown scripts of your distro.

-Mike


More information about the busybox mailing list