Translate

Image of Android Wireless Application Development
Image of Operating System Concepts
Image of Advanced Programming in the UNIX Environment, Second Edition (Addison-Wesley Professional Computing Series)
Image of RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)

Systemd and /etc/fstab

Once again Lennart Poettering and Kay Sievers have managed to complicate things and broken the simple model that served the Unix and Linux communities well for over 30 years, i.e. that details of filesystem mounts that should persist across a reboot are listed in /etc/(v)fstab.

With systemd, mount units may either be configured via unit files, or via /etc/fstab. Mounts listed in /etc/fstab are converted into native units dynamically using systemd-fstab-generator at boot time or when the system manager configuration is reloaded. In general, configuring mount points through /etc/fstab is the preferred approach.

A systemd unit configuration file whose name ends in “.mount” encodes information about a file system mount point controlled and supervised by systemd. If a mount point is configured in a unit file in both /etc/fstab and a unit file that is stored below /usr, the former will take precedence. If the unit file is stored below /etc, it will take precedence. This means that native unit files take precedence over traditional configuration files, but this is superseded by the rule that configuration files in /etc always take precedence over configuration files in /usr.

Here is an example of the mount file for /tmp on Fedora 20:

$ cat /usr/lib/systemd/system/tmp.mount

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Temporary Directory
Documentation=man:hier(7)
Documentation=http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target

[Mount]
What=tmpfs
Where=/tmp
Type=tmpfs
Options=mode=1777,strictatime

Here is an example of the output of systemd-fstab-generator for the /home/fpm line in /etc/fstab:

# grep FPMWORK /etc/fstab
LABEL=FPMWORK /home/fpm    ext4   defaults        0 3

# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Before=local-fs.target
RequiresOverridable=systemd-fsck@dev-disk-byx2dlabel-FPMWORK.service
After=systemd-fsck@dev-disk-byx2dlabel-FPMWORK.service

[Mount]
What=/dev/disk/by-label/FPMWORK
Where=/home/fpm
Type=ext4
FsckPassNo=3


Now you have more work to do to understand where and how pseudo files and pseudo and regular filesystems are mounted. It is no longer enough to just look at /etc/fstab.

Comments are closed.