fstab That Survives a Reboot and Doesn't Brick the Boot

The options and identifiers that keep a bad mount entry from stalling the entire machine

Contents

I once added a line to /etc/fstab for a USB drive I was about to plug in permanently, using /dev/sdb1 because that’s what lsblk showed at the time. Weeks later a firmware update changed enumeration order, that drive became /dev/sdc1, and the box sat at an emergency shell on every boot until I plugged in a monitor to find out why. The fstab file is one of the few places in Linux where a single wrong line can genuinely stop a headless machine from booting at all — worth understanding properly before you edit it casually.

Why device names are the wrong identifier

/dev/sdX naming is assigned at boot, in enumeration order, by whatever the kernel happens to detect first. That order isn’t guaranteed stable across reboots, especially with USB devices, hot-swap bays, or after adding/removing any storage device — the drive that was sdb can become sdc for reasons that have nothing to do with the drive itself. fstab entries keyed on /dev/sdX work until the day they don’t, silently, and the failure mode when they break is the worst kind: the boot process hangs waiting for a device that the kernel simply renamed, still physically present the whole time.

The inside of an opened hard disk drive showing platters, actuator arm and flex cable.
Inside a hard disk drive. The kernel names each drive by the order it is detected, which is why fstab entries should not rely on that name. Photo: Seagate ST33232A hard disk inner view by Eric Gaba (Sting - fr:Sting)  This image was created with CombineZP by 11 ( I, CC BY-SA 3.0, via Wikimedia Commons.

Use a UUID instead — an identifier baked into the filesystem itself at creation time, which follows the filesystem regardless of what bus, port or enumeration order it shows up under:

1
2
3
$ sudo blkid
/dev/sda1: UUID="8f4e2b91-6c3d-4a1f-9e7b-2d1c9a8b5e3f" TYPE="ext4" PARTUUID="..."
/dev/sdb1: UUID="3a7c9e12-88f4-4b6a-a9d3-1e5f8c2b7a90" TYPE="ext4" PARTUUID="..."

Or LABEL= if you set filesystem labels deliberately, which I actually prefer for anything I manage by hand since it’s human-readable in the fstab file itself rather than an opaque hex string:

1
2
3
$ sudo e2label /dev/sdb1 backup-drive
$ blkid /dev/sdb1
/dev/sdb1: LABEL="backup-drive" UUID="3a7c9e12-..." TYPE="ext4"

Either is stable across reboots and enumeration changes. /dev/sdX should only ever appear in fstab as a debugging convenience you replace before saving the file, never as the entry you actually leave running.

Anatomy of an fstab line

1
UUID=3a7c9e12-88f4-4b6a-a9d3-1e5f8c2b7a90  /mnt/backup  ext4  defaults,noatime,nofail  0  2

Six fields, each meaningful:

  1. Device — UUID or LABEL, per above.
  2. Mount point — must already exist as a directory (mkdir -p /mnt/backup first) or the mount fails.
  3. Filesystem type — ext4, xfs, nfs, cifs, auto (let the kernel detect it, fine for removable media, worth being explicit for anything permanent).
  4. Options, comma-separated, no spaces — covered below in detail.
  5. Dump — legacy dump backup utility flag, essentially unused today; 0 is correct on virtually every modern system.
  6. Pass — fsck order at boot. 0 skips fsck entirely, 1 for the root filesystem specifically, 2 for everything else that should be checked. Non-root filesystems should never be 1.

The options that actually matter

nofail is the single most important option on this list for anything that isn’t the root filesystem, and it’s the one people learn about only after their first fstab-caused boot hang. Without it, if the device fails to mount — unplugged drive, network share unreachable, a typo in the UUID — systemd’s generated mount unit blocks the boot sequence waiting for it, and a headless machine sits there until something (a timeout, eventually, or your manual intervention at a console) breaks the deadlock. nofail tells systemd this mount is not required for the system to consider itself booted; if it fails, boot continues and the mount is simply absent, which is a state you can diagnose and fix over SSH rather than one that locks you out of SSH in the first place.

A mount fails at bootWithout nofailsystemd waitsWith nofailboot carries onTimeout, thenemergency shellMount is absentfix it over SSHThe default start timeout is 90 seconds
What a failed mount does to the boot, with and without nofail.
1
UUID=3a7c9e12-...  /mnt/backup  ext4  defaults,nofail  0  2

noatime stops the filesystem from updating the last-accessed timestamp on every single file read, which is pure overhead for the vast majority of workloads — nothing on a homelab box is actually consuming atime data. Worth adding by default unless you specifically know something reads it (some mail servers and a handful of backup tools do; check before blanket-applying across a box you didn’t build yourself).

x-systemd.automount defers the actual mount until the mount point is first accessed, rather than at boot — genuinely useful for network shares or removable media where you’d rather boot fast and mount lazily than wait on something that might not be there yet:

1
UUID=3a7c9e12-...  /mnt/backup  ext4  defaults,nofail,x-systemd.automount,x-systemd.mount-timeout=10  0  2

x-systemd.mount-timeout= caps how long systemd waits before giving up on a specific mount, independent of nofail — the two work together well: nofail prevents a hang from blocking the whole boot, while mount-timeout prevents that individual mount attempt from hanging indefinitely in the background.

OptionWhat it doesTypical use
nofailBoot continues if the mount failsEvery non-root mount
noautoSkips the mount at bootOccasional drives
x-systemd.automountMounts on first accessNetwork shares, removable media
x-systemd.mount-timeout=Caps the wait for one mountSlow or remote mounts
_netdevOrders the mount after the networkNFS and CIFS
noatimeSkips access-time updatesMost data volumes

Network filesystems need extra care

NFS and CIFS/SMB mounts in fstab are the most common source of the boot-hang I opened with, because they depend on the network being up and the remote host being reachable — two things that aren’t guaranteed at the exact moment fstab-driven mounts are normally processed during boot.

1
192.168.1.50:/export/media  /mnt/media  nfs  defaults,nofail,x-systemd.automount,x-systemd.requires=network-online.target,_netdev  0  0

_netdev marks the mount as depending on network availability, which tells systemd to sequence it after networking comes up rather than treating it like local storage. x-systemd.requires=network-online.target makes that dependency explicit rather than implied. Both nofail and x-systemd.automount remain worth combining here — a NAS that’s rebooting when your server boots shouldn’t be able to stall your server’s boot in return.

For CIFS/SMB specifically, credentials belong in a separate, permission-restricted file, never inline in fstab where any local user with read access to the file can see them:

1
2
3
# /etc/samba/credentials/media-share (chmod 600, owned by root)
username=mediauser
password=examplepassword
1
//192.168.1.50/media  /mnt/media  cifs  credentials=/etc/samba/credentials/media-share,nofail,uid=1000,gid=1000,_netdev  0  0

Testing before you reboot

Never trust an fstab edit until you’ve validated it live — mount -a reads the file and attempts to mount everything not already mounted, without requiring an actual reboot to find out if the syntax is broken:

1
2
$ sudo mount -a
mount: /mnt/backup: wrong fs type, bad option, bad superblock on /dev/sdb1, missing codepage or helper program.

That error immediately tells you the entry has a problem, while you still have a working shell to fix it — vastly preferable to discovering the same error via a dead SSH session after a reboot. findmnt --verify goes further and checks the whole file for structural and logical problems (duplicate mount points, missing directories, unknown options) without attempting to actually mount anything:

1
2
3
$ sudo findmnt --verify
/mnt/backup                     : mount point does not exist
/mnt/media                      : more filesystems detected on /dev/sdb1

I run both before every fstab edit, in that order — findmnt --verify for the structural check, then mount -a to actually attempt the mounts and confirm the whole set applies cleanly.

fstab and systemd: it’s generated units underneath

Modern systemd-based distros don’t process fstab with a separate legacy mount script — systemd-fstab-generator reads it at boot and creates a .mount unit for every entry, which then participates in the same dependency graph as every other unit. This is worth knowing because it means fstab problems are debuggable with the exact same tools as any other systemd unit failure — no separate mechanism to learn:

1
2
3
4
$ systemctl status mnt-backup.mount
● mnt-backup.mount - /mnt/backup
     Loaded: loaded (/etc/fstab; generated)
     Active: failed (Result: exit-code) since Mon 2024-10-07 09:12:03 UTC

The mount point path gets translated into the unit name by replacing / with -, so /mnt/backup becomes mnt-backup.mount. journalctl -u mnt-backup.mount gives the actual mount failure reason in the same format covered in a systemd service won’t start — the fstab file is really just a friendlier syntax for defining systemd mount units, and every diagnostic habit that applies to a .service unit applies here too.

One consequence: after editing fstab, a systemctl daemon-reload regenerates these units from the new file. mount -a alone works for actually mounting things, but if you want systemd’s own view of the unit (its dependency ordering, its Before=/After=) to reflect a structural change you just made — adding x-systemd.automount, for instance — reload first:

1
2
$ sudo systemctl daemon-reload
$ sudo mount -a

Bind mounts: the fstab entry people forget exists

A bind mount makes a directory accessible at a second path without duplicating the data — genuinely useful for exposing part of one filesystem tree inside a container’s bind-mounted volume, or for restructuring paths without physically moving files. fstab supports these directly, and they’re worth knowing because the syntax looks unusual the first time:

1
/srv/media/movies  /mnt/plex/movies  none  bind,nofail  0  0

The filesystem type field is none (there isn’t one — it’s not a new filesystem, just a second mount point for an existing directory tree) and the options field carries bind instead of a normal mount option. nofail still applies and still matters: if the source directory doesn’t exist yet (a not-yet-mounted external drive that /srv/media itself lives on, say), you want the same graceful boot-continues behaviour as any other entry, since a convenience mount like this one isn’t worth stalling a boot over.

noauto: mounting on demand instead of at boot

nofail and noauto solve related but distinct problems, and conflating them is a common mistake. nofail lets boot continue if a mount fails; noauto skips attempting the mount at boot at all, leaving it to be triggered manually or by x-systemd.automount:

1
UUID=3a7c9e12-...  /mnt/archive  ext4  defaults,noauto,x-systemd.automount,x-systemd.mount-timeout=10  0  2

For an external drive that’s only plugged in occasionally, noauto alone means mount -a at boot won’t even try it, and mount /mnt/archive works whenever the drive happens to be connected. Pairing it with x-systemd.automount gets the best of both — nothing attempted at boot, but the first ls /mnt/archive (or any access to that path) triggers the mount transparently, without needing a manual mount command remembered after plugging the drive back in. Without x-systemd.automount, noauto alone means the mount point simply sits empty until someone runs mount by hand, which is the right choice for something genuinely occasional (an offline backup drive brought out once a month) versus the automount combination, which suits something that should feel present whenever it’s physically connected.

A worked example: adding a second drive without a reboot

The full sequence, in order, for a drive that’s already physically connected and partitioned — the same steps whether it’s a new NAS addition or a drive migrated in from another box:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
$ sudo blkid /dev/sdc1
/dev/sdc1: UUID="91a2f7c4-55e1-4b8a-b234-7c9d1e6f2a03" TYPE="ext4"

$ sudo mkdir -p /mnt/newdrive

$ echo 'UUID=91a2f7c4-55e1-4b8a-b234-7c9d1e6f2a03  /mnt/newdrive  ext4  defaults,noatime,nofail  0  2' | sudo tee -a /etc/fstab

$ sudo systemctl daemon-reload
$ sudo findmnt --verify
$ sudo mount -a

$ mount | grep newdrive
/dev/sdc1 on /mnt/newdrive type ext4 (rw,noatime)

Each step is individually cheap to check before moving to the next — findmnt --verify catches a typo’d UUID or a missing mount point before mount -a ever tries to act on it, and the final mount | grep confirms the entry actually took effect rather than trusting that a clean exit code from mount -a means everything mounted the way it was intended to. The whole sequence takes under a minute and never touches a running service or requires a reboot — the only time a reboot is genuinely worth doing afterward is to confirm the fstab entry survives one cleanly, which is worth doing once on a new entry rather than assuming mount -a succeeding today guarantees the same result after the next restart.

Edit/etc/fstabfindmnt--verifydaemon-reloadmount -aReboot onceto confirmRun in this order, while a working shell is still open
The order that catches a bad entry before the reboot does.

Troubleshooting

Boot hangs at “a start job is running for /mnt/whatever”. Missing nofail on a mount that can’t currently succeed. Boot into recovery/single-user mode (or wait out the timeout, usually 90 seconds by default), add nofail, and mount -a to confirm the fix without needing another reboot.

Mount succeeds manually but not at boot. Frequently a network-dependency ordering issue — the mount was attempted before the network (or the specific interface, or DNS) was actually ready. Add _netdev and x-systemd.requires=network-online.target for anything remote.

UUID= entry stopped working after reformatting the drive. Reformatting generates a new UUID — the old fstab entry now points at nothing. Re-run blkid and update the entry; this is the single most common “why did my mount disappear” cause after any disk maintenance.

Duplicate mount point defined twice. findmnt --verify catches this, but if you’re debugging manually: systemd builds one mount unit per mount point, so a second entry for the same path is unsupported and can fail the mount (or even drop the boot to emergency mode), while a plain mount -a processes both lines and stacks the later mount over the earlier — check for a leftover entry from an earlier edit before assuming systemd is doing something strange.

Mount works over SSH but a service that depends on it fails at boot anyway. A service unit that reads from a mount point needs an explicit RequiresMountsFor= dependency in its own unit file, or systemd has no guarantee it started the service after the mount was ready — nofail deliberately decouples the mount from boot success, which means nothing automatically blocks a dependent service from starting too early unless that dependency is spelled out.

If the entry you’re adding is a resized LVM volume, resizing an LVM volume covers making sure the UUID and mount options still match after a structural change to the underlying block device — a resize doesn’t usually change the UUID, but it’s worth confirming rather than assuming. If the mount is swap rather than a data filesystem, swap, swappiness and zram covers whether a disk-backed swap fstab entry is even the right call versus RAM-backed zram. And if a systemd-generated mount unit itself is the thing failing to start rather than the fstab syntax, a systemd service won’t start covers the same systemctl status/journalctl diagnostic method applied to .mount units specifically.

Verdict

Three habits prevent nearly every fstab-caused boot problem I’ve hit or seen reported: identify devices by UUID or LABEL rather than /dev/sdX, add nofail to anything that isn’t the root filesystem, and run mount -a before rebooting rather than after. None of that is exotic knowledge — it’s just the difference between an edit that’s been validated and one that’s been assumed correct.

Smarc
Written by Smarc

Founder and editor of Aside House. A lifelong tinkerer who self-hosts far more than is sensible, hardens Linux boxes for fun, and prods the latest AI tools to see what they can really do. The how-to guides here are the notes Smarc wishes had existed the first time round.

Smarc is the editor of Aside House. The homelab, the hardware and the opinions are real; the guides are drafted with AI assistance. Infrastructure details are genericised on purpose.