Skip to main content
RunBook Academy

LinuxXV · /etc/fstab and Mount ManagementNetwork filesystems

Network filesystems in fstab - _netdev, automount, and the boot you cannot watch

Intermediate⏱ ~15 minbashsystemctlfindmntmount

What you'll learn

  • Explain how systemd-fstab-generator classifies an entry as local or remote, and what _netdev changes
  • Write an NFS, CIFS and iSCSI-backed fstab entry that degrades instead of stopping the boot
  • Distinguish x-systemd.device-timeout, x-systemd.mount-timeout and DefaultTimeoutStartSec
  • Use x-systemd.automount deliberately, and recognise the failures it moves rather than removes
  • Detect data written underneath a mount point while the network filesystem was absent

Prerequisites

Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-11

Not yet marked complete on this device.

Every local entry in /etc/fstab is a statement about this host. A network entry is a statement about a different host, evaluated at boot, on a console you are not sitting at. The filer being down at 03:00 is not a hypothetical - it is the normal case that the entry has to survive.

The whole lesson is one question: when the remote side is not there, does this host boot without it, or does it stop and wait for a human?

How systemd decides an entry is remote

systemd-fstab-generator sorts every fstab line into one of two targets. The classification decides when the mount is attempted and what happens when it fails.

ClassificationOrdered beforeAttemptedOn failure without nofail
Locallocal-fs.targetEarly, as soon as the device unit appearslocal-fs.target fails, boot drops to emergency
Remoteremote-fs.targetAfter network-online.targetremote-fs.target fails, boot drops to emergency

The generator classifies by filesystem type. nfs, nfs4, cifs, smb3, ceph and the other well-known network types are treated as remote automatically. Anything else is local - and that is where the trap is.

Read-only / Safewhat systemd thinks is remote
$ systemctl list-dependencies remote-fs.target
remote-fs.target
* |-remote-fs-pre.target
* |-srv-share.mount
* |-srv-media.automount

Illustrative output

The three timeouts, which are not the same timeout

Almost every “the boot hung for 90 seconds” question is really a question about which of these three fired.

SettingWhat it boundsWhere it can be set
x-systemd.device-timeout=How long to wait for the device to show upfstab only - ignored in a .mount unit’s Options=
x-systemd.mount-timeout=How long the mount command itself may runfstab only - use TimeoutSec= in a unit
DefaultTimeoutStartSec=The fallback for any job with no explicit timeout/etc/systemd/system.conf

For an NFS mount the second one is what you want. The device already exists (there is no device), and what can hang is the mount.nfs call talking to a filer that is powered on, answers ICMP, and is not exporting anything.

Read-only / Safethe inherited default
$ systemctl show -p DefaultTimeoutStartUSec -p DefaultTimeoutStopUSec
DefaultTimeoutStartUSec=1min 30s
DefaultTimeoutStopUSec=1min 30s

A network entry that degrades

Read-only / Safetwo entries that will not stop a boot
$ grep -E 'nfs|cifs' /etc/fstab
nfs01.example.com:/export/data /srv/data nfs4 _netdev,nofail,x-systemd.mount-timeout=30,hard,noatime 0 0
//fs01.example.com/share /srv/share cifs _netdev,nofail,credentials=/etc/cifs/fs01.cred,vers=3.1.1,uid=1000,gid=1000 0 0

Read the option list as four separate decisions:

  1. _netdev - order me after the network. Free, and wrong only if the filesystem is genuinely local.
  2. nofail - my absence is not a reason to stop the boot. Correct for archives, media, scratch and reporting shares. Wrong for anything a service will write to; see below.
  3. x-systemd.mount-timeout=30 - give up on the attempt after 30 seconds rather than 90. Shorter boots, and a failure you can see in the journal at a predictable time.
  4. hard - once mounted, retry indefinitely rather than returning EIO into an application that may not check it.

The nofail decision is about what writes there

nofail is not a safety option to sprinkle everywhere. It changes which failure you get, and one of the two failures is much worse than the other.

Without the mount, /srv/data is still a directory - an empty one, on the root filesystem. A service that starts anyway writes into it happily, at root-filesystem speed, until the root filesystem fills. Then the filer comes back, the mount succeeds, and the data that was written underneath is shadowed: still consuming space, no longer visible under any path.

Configuration changelook underneath a mount
$ sudo mount --bind / /mnt/rootview && sudo du -sh /mnt/rootview/srv/data
4.2G	/mnt/rootview/srv/data

Illustrative output

The structural fix is not nofail and not its absence. It is to let the boot succeed and let the service carry the dependency:

# /etc/systemd/system/reporting.service.d/10-requires-mount.conf
[Unit]
RequiresMountsFor=/srv/data

Now the host boots, the mount failure is visible in systemctl --failed, and reporting.service refuses to start rather than writing 4 GB into the root filesystem. That is a far easier incident than an emergency prompt, and a far cheaper one than a shadowed directory nobody finds for a month.

Validating a network entry without rebooting

You cannot fully test boot-time behaviour without a boot. You can eliminate every failure that is not about timing:

Read-only / Safesyntax and reachability
$ sudo findmnt --verify --verbose
/srv/data
[ ] target exists
[ ] FS type is nfs4
[ ] options: _netdev,nofail,x-systemd.mount-timeout=30,hard,noatime

0 parse errors, 0 errors, 0 warnings

Illustrative output

Configuration changeread what the generator produced
$ sudo systemctl daemon-reload && systemctl cat srv-data.mount
# /run/systemd/generator/srv-data.mount
# Automatically generated by systemd-fstab-generator

[Unit]
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
SourcePath=/etc/fstab
After=network-online.target
Wants=network-online.target

[Mount]
What=nfs01.example.com:/export/data
Where=/srv/data
Type=nfs4
Options=_netdev,nofail,x-systemd.mount-timeout=30,hard,noatime
TimeoutSec=30s

Illustrative output

If After=network-online.target is missing, _netdev did not take effect and the entry is still classified as local. Fix that before rebooting, because the reboot is where you find out.

Knowledge check

Knowledge check · 4 questions

  1. Q1. An XFS filesystem on an iSCSI LUN is listed in fstab as `UUID=... /srv/lun0 xfs defaults 0 2`. The host boots to emergency mode. Why?

  2. Q2. x-systemd.device-timeout= and x-systemd.mount-timeout= can both be set either in /etc/fstab or in the Options= line of a .mount unit.

  3. Q3. Which of the following belong on an NFS entry for a reporting share that is not needed for the host to function? Select all that apply.

  4. Q4. A service wrote 4 GB into /srv/data while the NFS mount was missing. The filer is now back and the mount succeeded. What is the state of that data and how do you see it?

Passing score: 75%. Answers are checked in this browser.