Mounting and fstab
How a filesystem on a disk, partition, or network share gets attached into the single Linux directory tree, and how /etc/fstab makes that attachment happen automatically at boot.
Every filesystem - the root filesystem, a second disk, a USB drive, an NFS share - has to be mounted somewhere: attached to an existing directory (the mount point), after which its contents appear as if they'd always been part of the tree at that path. See The Filesystem Hierarchy for why Linux works this way instead of using per-drive letters.
Seeing what's mounted
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 238.5G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
└─sda2 8:2 0 238G 0 part /
sdb 8:16 0 1.8T 0 disk
└─sdb1 8:17 0 1.8T 0 part /data
lsblk shows the physical layout; mount with no arguments (or
findmnt, which formats it more readably) shows everything currently
mounted, including virtual filesystems like /proc and /sys.
Mounting manually
sudo mount /dev/sdb1 /mnt/data
sudo umount /mnt/data
A manual mount like this lasts only until the next reboot (or until unmounted) - useful for a USB drive or a one-off task, not for anything that needs to survive a restart.
/etc/fstab: mounts that persist across reboots
/etc/fstab lists filesystems the system should mount automatically at
boot. Each line has six whitespace-separated fields:
UUID=1a2b3c4d-... /data ext4 defaults 0 2
| Field | Meaning |
|---|---|
| 1 | What to mount - a device (/dev/sdb1), or (strongly preferred) a UUID= |
| 2 | Where to mount it (the mount point directory, must already exist) |
| 3 | Filesystem type (ext4, xfs, btrfs, nfs, …) - see Filesystem Types |
| 4 | Mount options, comma-separated (defaults, ro, noatime, …) |
| 5 | dump flag - legacy backup tool hint, almost always 0 |
| 6 | fsck pass order - 1 for root, 2 for other persistent filesystems, 0 to skip |
Use UUID= instead of /dev/sdX. Device names like /dev/sdb1 depend
on detection order at boot and can shift if you add or remove a drive,
silently mounting the wrong disk at a given path. A UUID is fixed to the
filesystem itself. Find it with:
blkid /dev/sdb1
/dev/sdb1: UUID="1a2b3c4d-5e6f-7890-abcd-ef1234567890" TYPE="ext4"
Testing an fstab change safely
A typo in /etc/fstab can leave a system unable to boot normally if it
affects a critical mount. Test before rebooting:
sudo mount -a
This mounts everything in /etc/fstab that isn't already mounted, using
the current file - if there's a syntax error or an invalid UUID, it
surfaces immediately instead of at the next boot.
Common mount options
defaults-rw,suid,dev,exec,auto,nouser,async(the standard baseline)noatime- skip updating file access times on every read; a meaningful performance win on busy filesystemsro- mount read-onlynoexec,nosuid- hardening options, often used for/tmpor removable media, disallowing execution or setuid binaries from that filesystem - see Hardening Basics
Network and on-demand mounts
Network filesystems (NFS, CIFS/SMB) use the same /etc/fstab mechanism
with a different filesystem type field, but a mount attempted before the
network is up at boot can hang startup. Modern systemd-based distributions
generate mount units from /etc/fstab automatically and support the
x-systemd.automount option, which defers actually mounting the share
until something first accesses that path.