s6-linux-init
Software
skarnet.org
The s6-linux-init-umountall program
s6-linux-init-umountall unmounts all the filesystems.
Interface
s6-linux-init-umountall
- s6-linux-init-umountall unmounts all partitions according to /proc/mounts.
It processes /proc/mounts in the reverse order, starting with the most recently mounted
partition and ending with the root filesystem ("unmounting" the root filesystem means remounting
it read-only).
- s6-linux-init-umountall does not touch /etc/mtab.
- If a filesystem fails to unmount, a warning is printed to stderr, but
s6-linux-init-umountall still attempts to unmount all the other ones.
Notes
- s6-linux-init-umountall is automatically called at the very end of the shutdown procedure,
in "stage 4", i.e. after a SIGKILL has been sent to all the processes on the system, and
right before the system reboots (or halts, or is powered off). By that point, there is
no possible process that could prevent real file systems from being unmounted.
- It is likely that some filesystems will still fail to unmount, typically
/proc and /dev. That's okay: those are pseudo-filesystems, and
will not cause data loss or a fsck if the system shuts down while they are still mounted.
- Distributions usually provide a umount command with a -a option
to unmount all filesystems. That command is usually bloated with historical artifacts
and relies on unsafe interfaces, so it was decided not to use it. The
s6-linux-utils package also
provides a s6-umount
command with a -a option, but adding a dependency to that package would be a
higher cost than simply reimplementing the specific functionality here.