Mounting
Common -o options: ro/rw, noexec, nosuid, nodev (security),
noatime (speed), _netdev (network filesystems).
Mounting filesystems: the mount command, persistent mounts in /etc/fstab, UUIDs and options.
lsblk -f
devices and filesystems
findmnt
the mount tree
blkid /dev/sdX1
UUID for fstab
sudo mount -a
apply fstab without a reboot (a check!)
sudo mount -o remount,rw /
remount root rw (recovery)
sudo mount --bind /srv/data /var/www/data
a bind mount
fuser -vm /mnt
who's holding the filesystem (for umount)
Linux has no "C:/D: drives" — the whole tree starts at /, and filesystems
are mounted onto directories (mount points).
/etc/fstab mounts filesystems at boot. Fields: what · where · type ·
options · dump · pass.
pass (the 6th field): 1 for root, 2 for others, 0 — skip fsck.Common -o options: ro/rw, noexec, nosuid, nodev (security),
noatime (speed), _netdev (network filesystems).
nofail is for data disks. Without it every fstab line is required for boot: if the
disk is missing, systemd waits for it and then stops the boot in emergency mode — and
someone has to get to the console. With nofail the system boots without the disk,
and the directory stays empty. Root / and /boot are never marked this way.
No reboot is needed to test it: sudo umount /srv/data, then sudo mount -a — if the
partition is back in the directory, the line is right.
mount answers wrong fs type, bad option, bad superblock on /dev/vdb, missing
codepage or helper program, or other error and suggests looking at dmesg. Most often the device has no filesystem: a whole new disk, or a partition before
mkfs. Check lsblk -f — the FSTYPE column is empty. A new disk is partitioned
first (fdisk-parted), then a filesystem is created and the partition is mounted
(/dev/vdb1, not /dev/vdb). Less often the cause is a wrong -t type or an option
the filesystem does not know; sudo dmesg | tail prints the details.
mount prints this hint after fstab is edited: systemd builds its own mount units from
the table and has not re-read it yet. Run sudo systemctl daemon-reload.
Something is using the filesystem. Find what: lsof +D /mnt/data or
fuser -vm /mnt/data. Close the processes, leave the directory (cd /), or
umount -l (lazy).
A bad line can drop the boot into emergency mode. Always run
sudo mount -a/findmnt --verify after editing. In recovery:
mount -o remount,rw / and fix fstab.
If the mount point already had files in it, they're "hidden" under the
mounted filesystem (not deleted). umount brings them back.
Without _netdev, the system waits for the filesystem before networking is
up. Add _netdev (and nofail for non-critical mounts) to the fstab
options (see nfs).
/dev/sdX names can shift between reboots — mount by UUID (blkid),
not by /dev/sdX.
Found an inaccuracy? Report an error in the article