s6-linux-utils: the fstab2s6rc program
Keywords: s6-rc fstab mount umount swapon swapoff swap filesystem boot offline conversion utility

s6-linux-utils
Software
skarnet.org

# The `fstab2s6rc` program

fstab2s6rc reads the `/etc/fstab` file, listing the filesystems and swap partitions to mount at boot time, and builds a set of service definition directories from it, meant to be fed to s6-rc-compile, having the effect of mounting these partitions when run by s6-rc.

This method has several advantages over the classic `mount -a`:

- Parallelization. Dependencies between the mount points are respected: if `/var` and `/var/log` are mount points in `/etc/fstab`, s6-rc will not attempt to mount `/var/log` before `/var` is successfully mounted. But apart from this necessary serialization, s6-rc will perform in parallel as much as it can.
- Granularity. `mount -a` in the boot sequence treats all the mounts as one unit; and although the output of fstab2s6rc can provide a bundle listing all the mounts, each mount is available as a separate service.

fstab2s6rc is an offline tool. It does not perform mounts or unmounts itself; it just converts the data in `/etc/fstab`, which is in a format usable by `mount`, into a format usable — after compilation — by s6-rc.

## Interface

         fstab2s6rc [ -A | -a ] [ -U | -u ] [ -E | -e ] [ -F fstab ] [ -m mode ] [ -B bundle ] [ -d basedep ] dir

- fstab2s6rc creates a directory dir in the filesystem to host all the service definition it will create. dir must not previously exist.
- fstab2s6rc reads the `/etc/fstab` file. For every mount defined in the file, it creates a subdirectory of dir that is a suitable definition directory for an s6-rc service performing that mount.
- The service is named after the mount point: the service mounting `/var/log` will be called `mount-var:log` (slashes being replaced with colons, first slash omitted).
- For swap partitions, the partition named is used: the service activating swap on `/dev/sda2` will be called `swap-dev:sda2`.

## Options

-F fstab, --fstab=fstab
  Read mount point information from file fstab instead of `/etc/fstab`.
-m mode, --mode=mode
  Create dir with permissions mode. mode is interpreted in octal.
-B bundle, --bundle=bundle
  Create a bundle named bundle containing all the created services. The mount point services will also be grouped under a bundle named `bundle-mounts` and the swap services will be grouped under a bundle named `bundle-swaps`. fstab lines that have the `noauto` option will not be included in these bundles.
-d dep, --base-dependency=dep
  Add a dependency to a service named dep to all the created services. This is useful e.g. in a boot sequence to ensure that the mounts will not start before a certain point.
-A, --include-noauto
  Include mount points and swaps marked `noauto` in the output. These services will not be marked as essential or recommended, and they will not be included in any bundle, but they will be there. This is the default.
-a, --exclude-noauto
  Exclude mount points and swaps marked `noauto`. No service will be created for these fstab entries.
-U, --without-uuid
  The created services will use s6-linux-utils commands such as s6-mount and s6-swapon. This makes the created services only depend on s6-linux-utils, but the fstab entries must not contain util-linux-specific syntax such as `UUID=` or `LABEL=` in place of device names (if they do, the fstab2s6rc invocation will work, but will generate nonsensical commands, interpreting the device names literally). This is the default.
-u, --with-uuid
  The created services will use util-linux commands such as mount and swapon. Running the services will depend on having such commands installed, but syntax for labels and uuids will be understood.
-E, --essential
  Mark the services as essential, and do not create `down` scripts for them. This makes services suitable to be part of a base init sequence where all the listed filesystems are mounted early, and never unmounted until right before the machine reboots. (`noauto` entries will not be marked as essential.) This is the default.
-e, --not-essential
  Mark the services as recommended rather than essential; create `down` scripts to unmount the filesystem. This makes services suitable for being called later than the base init sequence, as an optional part of a system's functionality. Stopping the services will unmount the corresponding filesystems and turn off the corresponding swap devices. `noauto` entries will not be marked as recommended.

## Exit codes

0
  Success.
1
  Invalid fstab file.
100
  Incorrect usage.
111
  System call failed.