What Is a Mount in Simple Terms
Linux has one directory tree starting at /. Everything is in that tree. But storage devices (hard disks, USB drives, network shares) are physically separate. Mounting is the act of attaching a storage device to a point in the tree so its files become accessible.
Think of it like plugging a filing cabinet into a specific drawer slot in a large cabinet system. Once plugged in, you can reach the files inside by opening that drawer — the files are still physically in the plugged-in cabinet, but accessible through the drawer slot.
How It Works
Before mounting, a storage device exists but its files are not accessible through the directory tree. After mounting at a mount point (any directory), the device's filesystem root appears at that directory.
Before mounting /dev/sdb1:/+-- etc/+-- var/+-- mnt/ +-- data/ <- empty directory After: mount /dev/sdb1 /mnt/data/+-- etc/+-- var/+-- mnt/ +-- data/ <- now shows contents of /dev/sdb1 +-- backups/ +-- archives/ +-- database.dumpCommon mount points:
/ Root filesystem -- always mounted/boot Boot partition (kernel, initrd)/home User home directories (often separate disk)/var Variable data -- often separate to prevent root fill/tmp Temporary storage (often tmpfs)/mnt Manual temporary mount point/media Auto-mounted removable media/data Common convention for additional data disksPractical Commands
## Show all currently mounted filesystemsmount## Or more readable:df -h ## Show type of each filesystemdf -Th## Filesystem Type Size Used Avail Use% Mounted on## /dev/xvda1 ext4 20G 12G 7.5G 62% /## tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm ## Mount a device manuallysudo mount /dev/sdb1 /mnt/data ## Mount with specific optionssudo mount -o ro /dev/sdb1 /mnt/data ## read-onlysudo mount -o noexec,nosuid /dev/sdb1 /mnt ## security optionssudo mount -t xfs /dev/sdc1 /mnt/data ## specify filesystem type ## Unmountsudo umount /mnt/data## or by device:sudo umount /dev/sdb1 ## Force unmount when busysudo umount -l /mnt/data ## lazy unmount -- waits for processes to finish ## Find what is using a busy mount pointlsof /mnt/data ## list open files on that mountfuser -v /mnt/data ## list processes using it ## Persistent mounts -- edit /etc/fstabcat /etc/fstab## UUID=abc123 /data xfs defaults,noatime 0 2 ## Test fstab without rebootingsudo mount -a ## mounts everything in fstab not already mounted ## Mount a network filesystem (NFS)sudo mount -t nfs 10.0.1.5:/exports/data /mnt/nfs ## Mount a tmpfs (RAM filesystem)sudo mount -t tmpfs -o size=2G tmpfs /tmpSecurity mount options:
ro Read-only -- cannot write to this filesystemnoexec Cannot execute binaries from this filesystemnosuid Setuid binaries have no effectnodev No device files on this filesystem Production pattern for /tmp:mount -o defaults,noexec,nosuid,nodev tmpfs /tmpThis prevents attackers from uploading and running binaries via /tmp.Common /etc/fstab example:
## device/UUID mountpoint fstype options dump passUUID=abc123-... / ext4 defaults 0 1UUID=def456-... /boot ext4 defaults 0 2UUID=ghi789-... /data xfs defaults,noatime 0 2tmpfs /tmp tmpfs nosuid,nodev,noexec 0 0Troubleshooting
| Symptom | Command | What to Look For |
|---|---|---|
| Mount fails | `dmesg | tail -20` |
| Cannot unmount, device busy | lsof /mountpoint |
Processes with open files |
| Mount does not persist after reboot | cat /etc/fstab |
Entry missing or wrong UUID |
| Disk full but df shows space | df -i /mountpoint |
Inode exhaustion |
PLACEMENT PRO TIP**Tip:** Use UUIDs instead of device names (`/dev/sdb1`) in `/etc/fstab`. Device names can change when disks are added or removed. UUIDs are stable. Get the UUID with: `blkid /dev/sdb1`.
COMMON MISTAKE / WARNING**Security:** Mount `/tmp` with `noexec,nosuid,nodev` on production servers. Many attacks work by uploading a binary to `/tmp` and executing it. The `noexec` option prevents binaries from running from `/tmp`, blocking this common attack vector.