s6-linux-init: the s6-linux-init-umountall program
Keywords: s6 linux administration root linux utilities umount unmount filesystem

s6-linux-init
Software
skarnet.org

# The `s6-linux-init-umountall` program

`s6-linux-init-umountall` unmounts all filesystems.

## Interface

         s6-linux-init-umountall

- `s6-linux-init-umountall` unmounts all filesystems 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).
- It makes an exception for the first instances of devtmpfs, proc and sysfs filesystem types, but not for later instances. In other words: it does not attempt to unmount `/dev`, `/proc` and `/sys`, but it will attempt to unmount duplicates of those pseudo-filesystems.
- `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.

## Exit codes

`s6-linux-init-umountall` returns the number of errors it encountered when attempting to unmount the filesystems listed in `/proc/mounts`.

## 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 cgroups or tmpfses. 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.