Mounting and fstab
Attach filesystems to the directory tree with mount, make them permanent in /etc/fstab by UUID, pick the options that matter, and check before you reboot.
Creating filesystems: ext4, XFS and BtrfsUnits, targets and dependencies
Mounting and fstab
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Linux has one directory tree. Mounting attaches a filesystem at a directory, the mount point, and hides whatever was in that directory until it is unmounted.
- /etc/fstab lists what to mount at boot: device, mount point, type, options, dump flag, fsck order. One line per filesystem.
- Refer to devices by UUID, PARTUUID or LABEL, never /dev/sdb1. Kernel device names can change between boots.
- systemd turns each fstab line into a .mount unit at boot. After editing fstab, run `systemctl daemon-reload`.
- nofail lets the boot continue if a non-essential disk is missing. Without it, a missing data disk can drop a server into emergency mode.
- noexec, nosuid and nodev take away execution, setuid and device files on a mount. relatime is the kernel default, and noatime goes further.
- Test before rebooting: `findmnt --verify`, then `mount -a` or mounting the one entry. A broken fstab is found at boot when you can least fix it.
One tree, many filesystems
Windows gives each filesystem a letter. Linux has a single tree starting at /, and every filesystem is attached somewhere in it. The root filesystem is /. A data disk might be attached at /srv/data, the EFI partition at /boot/efi, a network share at /mnt/backup. Attaching is called mounting, and the directory where a filesystem is attached is its mount point.
Think of a building where new wings are joined onto existing corridors. Walk through the door at /srv/data and you are in a different building, though the hallway looks continuous. df tells you which building you are in, and the disk usage lesson covers it.
mount and umount
From mount(8), not run here:
mount /dev/sdb1 /srv/data # type is detected
mount -o ro,noexec UUID=1b2c... /srv/data # by UUID, with options
umount /srv/data # fails with 'target is busy' if in use
findmnt # the tree of what is mounted
findmnt /srv/data # one mount: source, type, options
One surprise to know about: mounting over a non-empty directory hides its contents. The files are still on the parent filesystem, using space, invisible until you unmount. A full root filesystem whose du cannot find the space sometimes turns out to be files written into a mount point while the disk was not mounted.
umount refuses while a process has a file open or its working directory inside. findmnt and lsof +f -- /srv/data show who.
/etc/fstab, from a real system
/etc/fstab lists what to mount at boot. To show a real one, I read it out of Debian’s official Debian 13 cloud image. I fetched only the needed blocks of the image with HTTP range requests and followed the ext4 structures to /etc/fstab with a small reader I wrote in Python, on this Mac. This is the file exactly as Debian ships it:
PARTUUID=f99060f9-6889-4376-b790-9db94ddf75d7 / ext4 rw,discard,errors=remount-ro,x-systemd.growfs 0 1
PARTUUID=d98a63c0-4e9e-47b1-b7dd-b941f93a4327 /boot/efi vfat defaults,umask=077 0 2
Six fields per line, per fstab(5):
- What:
PARTUUID=f99060f9-.... That is the unique GUID of GPT partition 1, the root partition from the partitions lesson. I checked it against that image’s partition table, and it matches. - Where:
/. - Type:
ext4. - Options:
rw,discardto pass deletes to the underlying storage,errors=remount-roto go read-only on filesystem errors rather than keep writing to a damaged disk, andx-systemd.growfs, whichsystemd.mount(5)says grows the filesystem to fill its device. That is how a cloud VM given a bigger disk than the image ends up with a bigger root. - Dump: 0. Used by the old
dumpbackup tool, almost always 0. - fsck order: 1 for the root, 2 for others, 0 for never. systemd treats it as a simple on or off.
Why not /dev/sdb1
Kernel names like /dev/sdb1 are handed out in detection order. Add a disk, change a controller, boot a VM on a different host, and sdb can become sdc. An fstab that says /dev/sdb1 then mounts the wrong disk or none. Use one of:
UUID=: the filesystem’s UUID, printed byblkidandlsblk -f. Changes if you recreate the filesystem.PARTUUID=: the partition’s GPT GUID. Survives reformatting, as Debian’s image uses.LABEL=: a name you set atmkfstime. Readable, but must be unique.
Options that matter on a server
From mount(8) and systemd.mount(5):
| Option | Effect |
|---|---|
nofail |
Missing device does not fail the boot. The mount becomes wanted, not required, by local-fs.target |
noauto |
Do not mount at boot, only on request |
x-systemd.automount |
Mount on first access instead of at boot |
x-systemd.device-timeout=10s |
How long to wait for the device before giving up |
_netdev |
Needs the network, so wait for it |
noexec |
Programs on this filesystem cannot be executed directly |
nosuid |
Ignore setuid, setgid and file capabilities, see the special bits lesson |
nodev |
Ignore device files |
noatime |
Never update access times. relatime, the kernel default since 2.6.30, already avoids most of the cost |
ro |
Read-only |
nofail is the one that saves outages. Without it, a dead secondary disk turns into a server stuck in emergency mode, with only a console to fix it. noexec,nosuid,nodev suit mounts that hold data rather than programs, such as /tmp or upload directories. They raise the bar for an attacker, but a script can still be run with sh script, so they are a layer, not a wall.
systemd mount units
At boot, systemd-fstab-generator(8) translates each fstab line into a .mount unit named after its mount point: /srv/data becomes srv-data.mount. So mounts take part in the dependency graph from the units lesson, and systemctl status srv-data.mount shows why one failed. The generator runs again on systemctl daemon-reload, so after editing fstab, reload, or systemd keeps using the old units. You can also write .mount units directly, which the Learn Linux TV video in deeper walks through.
Check before you reboot
A typo in fstab is found at the next boot, possibly from a remote console. Test first:
findmnt --verify # parse fstab, check sources and types exist
systemctl daemon-reload
mount -a # mount everything not yet mounted, errors show now
mount(8) notes that many systemd distributions do not use mount -a at boot, so it is a test of the entries, not an exact replay of boot. mount /srv/data for the one changed line is the most direct test.
About the video
The embed is a clip, 4:11 to the end, of Learn Linux TV’s “Why You NEED UUIDs in fstab (Linux Storage Explained)”, July 2026. The clip’s chapters are a real server failure caused by not using UUIDs, finding a disk’s UUID step by step, editing /etc/fstab to use UUIDs instead of device names, and verifying fstab changes before rebooting. The cut skips the intro, the “why UUIDs matter” chapter that this lesson covers in its own words, and a plug for the presenter’s book. It does not cover mount options, nofail or systemd mount units, which the lesson adds. English was judged from the channel and English auto-captions, and content from the chapters and description.
What was run: reading the partition table and /etc/fstab out of Debian’s official cloud image with range requests and my own GPT and ext4 reader, on macOS. Mount behaviour is from mount(8), fstab(5) and findmnt(8) on man7.org and the systemd 262 man pages, checked 2026-11-28.
Where this fits
A partition has a fixed size, and growing one usually means moving others. A layer between disks and filesystems removes that limit: logical volumes with LVM.
Check yourself
A server with a second data disk fails to boot after that disk dies, landing in emergency mode. What fstab option would have let it boot?
nofail. The mount then becomes wanted rather than required by local-fs.target, so the boot continues without it.
Why does the Debian cloud image's fstab use PARTUUID= for the root rather than /dev/vda1?
The partition's GPT GUID stays the same whatever the disk is called on a given VM, while /dev/vda1 or /dev/sda1 depends on the hardware and detection order.
You mount a disk at /srv/data and the 20 GB of files that were in /srv/data disappear. Are they gone?
No. They are hidden under the mount. Unmount, or bind-mount the parent elsewhere, and they are still there, using space on the root filesystem.
You edited /etc/fstab. What two commands check it before a reboot?
`findmnt --verify` to check syntax and that sources exist, then `systemctl daemon-reload` and `mount -a`, or `mount /mountpoint` for the changed entry, to prove it mounts.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.