Mounts made by hand disappear at reboot. The file /etc/fstab lists the filesystems the system should know about and how to mount them.
The six fields
# device mount point type options dump pass
UUID=0a3b1c2d-1111-4222-8333-944455556666 / ext4 defaults 0 1
UUID=5ef4138f-5574-4227-8c74-58be9b62c010 /srv/data ext4 defaults 0 2Fields are separated by spaces or tabs:
- What to mount:
UUID=,LABEL=, a device path, or something likeserver:/sharefor NFS. - Where: the mount point. Swap entries use
none. - Type:
ext4,xfs,vfat,swapand so on. - Options: comma separated.
- Dump: used by the old
dumpbackup tool, normally0. - Pass: the order for filesystem checks at boot. Use
1for the root filesystem,2for others, and0to skip.
Use UUIDs
Device names can change between boots. Get the UUID with:
$ sudo blkid /dev/sdb1
/dev/sdb1: UUID="5ef4138f-5574-4227-8c74-58be9b62c010" TYPE="ext4"Useful options
defaults: the usual set, including read-write.noauto: do not mount automatically at boot.nofail: do not treat a missing device as a boot failure. Good for removable or optional disks.ro,noexec,nosuid: restrict what is allowed.
Edit safely
A mistake here can leave a system stuck in emergency mode at boot. Back up first:
$ sudo cp /etc/fstab /etc/fstab.bakCreate the mount point, add your line, then check and apply:
$ sudo findmnt --verify
$ sudo mount -a
$ findmnt /srv/datamount -a mounts everything in the file that is not already mounted, except entries marked noauto. If it prints an error, fix the line before rebooting. findmnt --verify is available in reasonably recent versions of util-linux.
On systems using systemd, run sudo systemctl daemon-reload after editing, because systemd generates mount units from this file.
Once an entry exists, you can mount it using just the mount point: sudo mount /srv/data.
Try it
Run cat /etc/fstab and identify all six fields on each line. Compare the UUIDs with the output of lsblk -f. Read man fstab, and only edit the file on a machine you can afford to repair.
Check your understanding
/etc/fstab
All 5 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.