Mounting and Unmounting

Linux does not give every storage device its own traditional drive letter or easy-to-remember access path. Instead, it organizes local disks, removable media, and network shares through one unified directory tree. To work with a storage device, Linux must first connect that device to a specific location inside the tree. This connection is called mounting, and the destination directory is known as the mount point. When the device is no longer needed, Linux removes that connection through a process called unmounting.
At first glance, mounting can sound like a simple way to “attach” a disk. In Linux, it is more precise than that. Mounting means taking the root of another filesystem and placing it at a chosen node in the existing directory hierarchy.

After a successful mount, the user or system can access the files inside the mounted filesystem simply by referring to the mount point. For example, once /dev/sdb1 is mounted at /mnt/usb, commands such as ls /mnt/usb show the contents of that device.

Several points are important to understand:

  • The mount point must be an existing directory, often created under /mnt or /media.
  • While the filesystem is mounted, contents from the mounted filesystem may hide anything that already existed in the mount point directory.
  • After unmounting, the original directory contents become visible again.
  • A single mount point can host only one filesystem at a time.

Mounting a Storage Device

The primary command for mounting is mount. Its basic form usually requires a device and a mount point:

mount [options] device mount_point

Common examples include mounting a USB drive, an ISO image, or an NFS share.

For a USB stick using the FAT or vFAT filesystem, the process might look like this:

sudo mkdir -p /mnt/usb
sudo mount -t vfat /dev/sdb1 /mnt/usb

To mount an ISO image as a loop device:

sudo mount -o loop ubuntu.iso /mnt/iso

To mount a network share over NFS:

sudo mount -t nfs 192.168.1.100:/share /mnt/nfs

The mount command offers several useful options:

  • -t sets the filesystem type, such as ext4, xfs, vfat, ntfs, or nfs.
  • -o sets mount options, such as ro for read-only, rw for read-write, or loop for loop devices.
  • -a mounts all filesystems listed in /etc/fstab that are not yet mounted.

Once the operation finishes, it is often useful to verify the result:

mount | grep sdb1
df -h

Unmounting a Storage Device

Unmounting is the inverse operation. It tells the kernel to detach the filesystem from the directory tree. The command is usually:

sudo umount /mnt/usb

Or, alternatively:

sudo umount /dev/sdb1

A safe unmount requires that no process is actively using the filesystem. If the device is busy, Linux may refuse the operation and report something like device is busy.

To resolve this, common steps include:

  1. Use lsof /mnt/usb or fuser -mv /mnt/usb to find the process holding the mount.
  2. Close the application or stop the process.
  3. Change the current directory out of the mount point with cd.
  4. Run the unmount command again.

For emergency situations, umount -l can perform a lazy unmount. The kernel will detach the filesystem once it becomes idle, but this is not a substitute for a normal unmount.

Automating Mounts at Boot

Manual mounts disappear after a reboot. If a filesystem should be available automatically at startup, it can be added to /etc/fstab.

The file generally contains six fields per entry:

device mount_point type options dump fsck order
/dev/sdb1 /data ext4 defaults 0 2

It is usually better to use a UUID instead of a device name such as /dev/sdb1, because device names can change depending on hardware configuration. To find a UUID, use:

sudo blkid /dev/sdb1

After editing /etc/fstab, run:

sudo mount -a

This attempts to mount all entries listed in the file. If something is misconfigured, it may cause boot problems, so backing up the file before editing is wise.

On systems using systemd, reloading the manager configuration may also be necessary:

sudo systemctl daemon-reload

Practical Safety Tips

  • Always unmount before removing or physically disconnecting a storage device.
  • Avoid pulling out USB drives or external disks while files are being written.
  • Check for processes using a mount before unmounting.
  • Back up /etc/fstab before making changes.
  • Use mount -a to verify that all entries in /etc/fstab are valid.

Final Thoughts

Mounting and unmounting are basic but essential skills for Linux system administration. They allow users to connect local media, optical drives, network shares, and other filesystems to the broader system. By understanding how the single directory tree works, how mount points function, and how to use mount, umount, and /etc/fstab, administrators can manage storage resources more effectively and safely.