Mounting Filesystems

In Linux, every piece of storage — a hard disk partition, a USB stick, a CD image, even another server’s shared folder — has to be mounted before you can read or write files on it. Mounting is the act of attaching a filesystem to a specific point in the single, unified directory tree that starts at /. Unlike Windows, where each disk gets its own drive letter, Linux makes every disk simply appear as a folder somewhere under /. Understanding mounting is essential for working with external drives, disk images, network shares, and for keeping a server’s storage configured correctly across reboots.

Overview: How Mounting Works

Linux presents all files and directories as one tree rooted at /, no matter how many physical or virtual storage devices are actually involved. When the kernel boots, only the root filesystem (the disk partition holding /) is attached to that tree. Every other filesystem — a second partition, a USB drive, an ISO image, a network share — starts out completely invisible to running programs. Mounting is the operation that grafts a filesystem onto a directory (called the mount point), making its contents appear at that location.

Under the hood, the kernel maintains a component called the VFS (Virtual File System), an abstraction layer that lets wildly different filesystem types — ext4, XFS, Btrfs, FAT32, NTFS, ISO9660, NFS — all be accessed with the same system calls (open, read, write, and so on). When you run mount, the kernel reads the filesystem’s superblock (metadata describing its layout), registers it in the VFS, and records that any path beginning with the mount point should now be resolved against that filesystem’s data instead of whatever used to be at that directory. Any files that existed in the mount point directory before mounting are not deleted — they are simply hidden until you unmount again.

A mount point is just an ordinary empty directory; nothing marks it as special except the fact that the kernel currently has something mounted there. You can mount a filesystem on any directory you own permissions for, though system convention reserves /mnt for temporary, manual mounts and /media for removable media that a desktop environment auto-mounts.

Syntax

mount [options] <device> <mount_point>
umount <device_or_mount_point>
Option Meaning
-t <type> Filesystem type (ext4, xfs, vfat, ntfs, iso9660…). Usually auto-detected.
-o <options> Comma-separated mount options, e.g. -o ro,noexec.
-a Mount everything listed in /etc/fstab that isn’t already mounted.
-r / ro Mount read-only.
-w / rw Mount read-write (default).
--bind Bind-mount one directory onto another instead of mounting a device.
-l (loop, in -o loop) Mount a file (e.g. an .iso) as if it were a block device.

Common options used with -o: noexec (disallow running binaries from this filesystem), nosuid (ignore setuid bits), nodev (ignore device files), noatime (don’t update access-time metadata on every read, for performance), defaults (rw, suid, dev, exec, auto, nouser, async), and nofail (don’t halt boot if this filesystem is missing — important for removable drives listed in /etc/fstab).

Examples

Example 1: Mounting a USB drive

lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk
└─sda1   8:1    0 465.8G  0 part /
sdb      8:16   1  14.9G  0 disk
└─sdb1   8:17   1  14.9G  0 part

lsblk lists block devices and shows that sdb1 (the USB stick) has no mount point yet. Create a mount point and mount it:

sudo mkdir -p /mnt/usb
sudo mount /dev/sdb1 /mnt/usb
df -h /mnt/usb
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1        15G  2.1G   12G  15% /mnt/usb

The kernel auto-detected the filesystem type (vfat, in this case) and attached it at /mnt/usb. df -h confirms the mount and shows how much space is used. When finished, unmount it with sudo umount /mnt/usb before physically removing the drive — otherwise buffered writes may never reach the disk.

Example 2: Persistent mounts with /etc/fstab

Manual mount commands don’t survive a reboot. To mount a filesystem automatically every time the system starts, add an entry to /etc/fstab. First find the partition’s UUID (a stable identifier that doesn’t change if device names shift):

sudo blkid /dev/sdc1
/dev/sdc1: UUID="3f2a9c1e-8b7d-4e21-9c3a-1d4f5e6b7a8c" TYPE="ext4" PARTUUID="..."
sudo mkdir -p /data
echo 'UUID=3f2a9c1e-8b7d-4e21-9c3a-1d4f5e6b7a8c  /data  ext4  defaults,noatime  0  2' | sudo tee -a /etc/fstab
sudo mount -a

The /etc/fstab line has six fields: device (by UUID), mount point, filesystem type, options, the dump flag (backup utility hint, usually 0), and the fsck pass number (0 = never check, 1 = check first for the root filesystem, 2 = check after). Running sudo mount -a mounts everything in fstab that isn’t mounted yet — this is the safe way to test a new entry without rebooting, because a broken fstab line can otherwise drop a server into an emergency boot shell.

Example 3: Loop-mounting an ISO and a bind mount

sudo mkdir -p /mnt/iso
sudo mount -o loop,ro ~/downloads/ubuntu-24.04.iso /mnt/iso
ls /mnt/iso
boot  casper  dists  EFI  install  isolinux  pool  README.diskdefines

The loop option tells the kernel to treat the ISO file itself as a block device, so its contents can be mounted read-only just like a physical CD. A related but different technique is a bind mount, which makes an existing directory visible at a second location without touching any device at all:

sudo mkdir -p /srv/www/shared
sudo mount --bind /home/alice/public_html /srv/www/shared

Now /srv/www/shared and /home/alice/public_html refer to the exact same underlying directory — files created in one instantly appear in the other, which is useful for exposing part of a user’s home directory to a chrooted or containerized service.

How It Works Step by Step

  1. You run mount /dev/sdb1 /mnt/usb. The mount command issues the mount() system call to the kernel, passing the device path, target directory, filesystem type (or asks the kernel to probe for one), and options.
  2. The kernel reads the device’s superblock, a small region of the filesystem that stores metadata: filesystem type, size, block size, and the location of the root directory structure for that filesystem.
  3. The kernel registers a new entry in its internal mount table, linking the mount point’s directory inode to the root inode of the new filesystem.
  4. From that moment, any path lookup that crosses /mnt/usb is redirected by the VFS to the newly mounted filesystem instead of the empty directory that used to be there.
  5. When you run umount /mnt/usb, the kernel flushes any buffered writes to disk, removes the mount table entry, and the original (now empty-again) directory reappears. If any process still has an open file or a working directory inside the mount point, umount fails with target is busy until that process closes it.

Common Mistakes

Mistake 1: Unmounting a filesystem that’s in use

cd /mnt/usb
sudo umount /mnt/usb
umount: /mnt/usb: target is busy.

Your shell’s current directory is still inside /mnt/usb, so the kernel refuses to unmount it. Fix it by leaving the directory first, then unmounting:

cd ~
sudo umount /mnt/usb

Mistake 2: A bad /etc/fstab entry blocking boot

If you add a line for a USB drive that isn’t always plugged in, and forget the nofail option, the system can hang at boot waiting for a device that never appears:

/dev/sdb1  /mnt/usb  ext4  defaults  0  2

Add nofail (and typically noauto, so it isn’t even attempted automatically) for removable media:

UUID=3f2a9c1e-8b7d-4e21-9c3a-1d4f5e6b7a8c  /mnt/usb  ext4  defaults,nofail,noauto  0  2

Mistake 3: Using /dev/sdX names in fstab instead of UUIDs

Device names like /dev/sdb1 can shift between reboots if you add or remove drives — what was sdb yesterday might be sdc tomorrow, silently mounting the wrong disk at a mount point. Always use UUID=... (from blkid) or /dev/disk/by-uuid/... in fstab instead of the raw device name.

Best Practices

  • Always test a new /etc/fstab line with sudo mount -a before rebooting — a syntax error can otherwise drop the machine into an emergency shell at boot.
  • Reference devices in fstab by UUID, not by /dev/sdX, since device letters aren’t guaranteed stable across boots.
  • Add nofail (and usually noauto) for any removable or non-essential mount in fstab so a missing drive never blocks the whole boot process.
  • Use findmnt or df -h to inspect what’s currently mounted, and lsblk to see available block devices before mounting.
  • Unmount external drives with umount before physically disconnecting them, so buffered writes are flushed to disk.
  • Mount untrusted media (like a USB stick from an unknown source) with noexec,nosuid,nodev to reduce the risk of it running code.
  • Use mount -o remount,rw / (not a full unmount) if you need to change the root filesystem’s mount options while it’s in use.

Practice Exercises

  1. Plug in a USB drive (or attach a spare disk image), use lsblk to identify its device name, create a mount point under /mnt, and mount it manually. Confirm with df -h that it’s mounted, then unmount it safely.
  2. Find the UUID of your mounted drive with blkid, add a nofail,noauto entry for it to /etc/fstab, and verify the entry works by running sudo mount -a without errors.
  3. Create two directories, ~/source_data and ~/mirror_view. Bind-mount the first onto the second, create a file inside ~/source_data, and confirm it instantly appears in ~/mirror_view. Then unmount the bind mount.

Summary

  • Mounting attaches a filesystem (a disk, partition, ISO, or another directory) to a directory in the single Linux directory tree, making its contents accessible at that path.
  • mount <device> <mount_point> attaches a filesystem manually; umount detaches it, and fails if the mount point is still in use.
  • /etc/fstab defines filesystems to mount automatically at boot, using six fields: device, mount point, type, options, dump, and fsck pass.
  • Always identify devices in fstab by UUID (via blkid), never by a /dev/sdX name that can change.
  • Use nofail and noauto for removable drives so a missing device never stalls the boot process.
  • A loop mount lets you mount a file (like an .iso) as if it were a block device; a bind mount makes one directory visible at a second path with no device involved at all.
  • Tools like lsblk, df -h, and findmnt let you inspect block devices and current mounts before and after mounting.