VMware ESXi and vSphere Cluster Management

Mount and Unmount File Systems in Linux

Learn how Linux mounts work, how to mount partitions and removable media, safely unmount devices, troubleshoot busy mounts, and configure persistent mounts with /etc/fstab.

In Linux, mounting is the operation of attaching a file system to a directory in the existing directory hierarchy. After mounting, the files on that file system are accessible through the selected directory, called the mount point.

Mounting does not copy files from a disk or partition. It makes the file system's existing contents available at a path. Linux mounts its root file system at /; other file systems can be mounted at directories below it, such as /mnt/data or /media/usb.

Devices, partitions, and file systems

Three concepts are important:

  • A storage device is physical storage, such as a hard disk, SSD, USB drive, or optical disc.
  • A partition is a logical subdivision of a storage device. For example, /dev/sdb1 commonly means the first partition on the device represented by /dev/sdb.
  • A file system is the on-disk format that organizes files and directories. Common types include ext4, XFS, vfat, and ISO 9660.

Linux represents block devices and partitions with device files, usually under /dev. Examples include:

  • /dev/sdb1: a partition on a disk or USB storage device.
  • /dev/sr0: a commonly used device name for a CD/DVD drive.
  • Removable storage may receive names such as /dev/sdc1, depending on which devices are connected.

A device or partition normally needs a valid, supported file system before it can be mounted. An unformatted partition is not made usable merely by attaching it to a directory. Creating a file system is a separate operation, commonly performed with tools such as mkfs.

View file systems that are currently mounted

Run mount without arguments to list active mounts:

mount

A typical line contains the following information:

/dev/sdb1 on /mnt/data type ext4 (rw,relatime)
  • /dev/sdb1 is the source device.
  • /mnt/data is the mount point, or target directory.
  • ext4 is the file system type.
  • rw,relatime are mount options. Here, rw permits writing and relatime controls timestamp updates.

findmnt provides a clearer, structured view of the mount tree:

findmnt

To view capacity and available space for mounted file systems, use:

df -h

The -h option displays sizes in human-readable units such as GiB and MiB. These commands inspect mounts; they do not mount or unmount anything.

Common Linux mount commands
CommandPurposeExample use
mountList currently mounted file systemsmount
findmntDisplay a structured mount-tree viewfindmnt /mnt/data
df -hShow mounted file system capacity and free spacedf -h /mnt/data
mount with a source and targetPerform a one-time manual mountsudo mount /dev/sdb1 /mnt/data
umountDetach a mounted file systemsudo umount /mnt/data
mount -aAttempt applicable entries from /etc/fstabsudo mount -a

Create and choose a mount point

The target directory must already exist. Create one with mkdir:

sudo mkdir -p /mnt/data

The -p option creates missing parent directories and does not report an error if the directory already exists. Conventional temporary locations include /mnt and /media. A mount point can be another suitable empty directory, but choosing a clear name makes administration easier.

Mount a file system manually

The general command structure is:

sudo mount [options] device mount-point

Administrative privileges are generally required because mounting changes the system-wide file system hierarchy. The optional -t argument specifies the file system type:

sudo mount -t file-system-type device mount-point

Linux can often detect the type automatically, so this is usually sufficient when the device has a recognizable file system:

sudo mount /dev/sdb1 /mnt/data

This example attaches the file system on /dev/sdb1 to /mnt/data. The files then become available under that directory, for example /mnt/data/report.txt.

Mount a CD or DVD

After inserting optical media, create a mount point and mount the optical device. /dev/sr0 is a common device name:

sudo mkdir -p /mnt/cdrom
sudo mount -t iso9660 /dev/sr0 /mnt/cdrom

Some systems detect ISO 9660 automatically, allowing:

sudo mount /dev/sr0 /mnt/cdrom

Use the type explicitly when detection is unavailable or when you need to confirm that the expected format is being used.

Mount read-only or read-write

Mount options control behavior. Use -o ro for read-only access:

sudo mount -o ro /dev/sdb1 /mnt/data

A read-only mount permits reading but prevents writes. It is useful for media that should not be changed or while investigating a questionable file system. rw requests read-write access:

sudo mount -o rw /dev/sdb1 /mnt/data

Read-write access may be the default for a file system that supports it, but specifying the option can make the intended behavior clear.

Useful mount options
OptionEffectAppropriate use
defaultsUses the system's standard option setCommon starting point for persistent local mounts
roMounts read-onlyProtected media or investigation of a file system
rwMounts read-writeNormal storage that must be modified
noautoDoes not mount the entry when mount -a runsRemovable media that should be mounted manually
userAllows a permitted non-root user to mount the file systemSome controlled removable-media setups; use according to local policy

Verify a successful mount

After mounting, verify both the source and the target. Several checks are useful:

mount
findmnt /mnt/data
ls -la /mnt/data
df -h /mnt/data

Confirm that:

  • The intended device or UUID appears as the source.
  • The intended directory appears as the target.
  • The file system type is expected, such as ext4 or iso9660.
  • The active options, such as ro or rw, match your intention.
  • ls displays the expected contents and df -h reports the expected capacity.

Unmount a file system safely

The command is spelled umount, not unmount. You can identify the mounted file system by its mount point:

sudo umount /mnt/data

Or identify it by its device path:

sudo umount /dev/sdb1

Unmounting detaches the file system from the directory tree. It is required before removing removable media or performing maintenance. Unmounting also gives the system an opportunity to finish pending writes safely.

The shell's current directory must not be inside the file system being unmounted. Open files, running applications, and nested mounts must also be dealt with before unmounting.

Resolve a busy mount point

A target is busy error means that something is still using the file system. Common causes include:

  • A shell whose current directory is inside the mount.
  • An application with an open file there.
  • A process using a file or subdirectory.
  • A nested file system mounted below the target.

First move to a directory outside the mount:

cd /
sudo umount /mnt/data

If it is still busy, use available investigation tools:

sudo lsof +D /mnt/data
sudo fuser -vm /mnt/data

lsof lists open files, while fuser identifies processes using a path or file system. Close the relevant application or stop the appropriate process, check for nested mounts with findmnt, and retry umount.

Persistent mounts with /etc/fstab

/etc/fstab is the system configuration file that records file systems intended to be mounted consistently. System startup uses it to coordinate boot-time mounts, and mount -a attempts to mount applicable entries from it.

Before editing this file, make a backup and ensure that the target directory exists:

sudo cp /etc/fstab /etc/fstab.backup
sudo mkdir -p /mnt/data

A typical persistent entry is:

UUID=<filesystem-uuid> /mnt/data ext4 defaults 0 2
/etc/fstab field reference
Field positionField namePurposeTypical value
1SourceIdentifies the device or file system to mountUUID=<filesystem-uuid>
2Mount pointDirectory where the file system becomes accessible/mnt/data
3File system typeSpecifies the on-disk formatext4
4OptionsControls mount behaviordefaults
5DumpLegacy backup utility field; commonly disabled0
6fsck passControls file system check ordering at boot2 for many non-root local file systems

Use UUIDs for persistent storage

A device name such as /dev/sdb1 can change when hardware is added, removed, or detected in a different order. A UUID is a unique identifier associated with a file system and is more stable for persistent configuration.

Find available file system UUIDs and types with:

sudo blkid

Use the UUID and the confirmed type in /etc/fstab. Do not copy the angle brackets in the example; replace them with the actual identifier.

Test an fstab entry before rebooting

After saving the file, test its applicable entries:

sudo mount -a

Check the command's output and then verify the result:

findmnt /mnt/data
df -h /mnt/data

Correct any UUID, type, mount-point, or option errors before rebooting. An incorrect /etc/fstab entry can cause a mount failure during startup and may affect boot behavior.

Common persistent options include:

  • defaults: a conventional standard option set.
  • ro: mount read-only.
  • rw: mount read-write.
  • noauto: do not mount automatically through mount -a; useful for removable media.
  • user: allow a non-root user to mount the entry, subject to the system's security policy.

An optical-media entry that should not be mounted automatically might look like this:

/dev/sr0 /mnt/cdrom iso9660 ro,noauto 0 0

With a configured entry, mount can use /etc/fstab when given a configured device or mount point instead of both an explicit source and destination. For example, after an entry exists for /mnt/data, this can use the matching configuration:

sudo mount /mnt/data

By contrast, a command containing both a device and a destination is a direct, one-time manual mount:

sudo mount /dev/sdb1 /mnt/data

mount -a attempts all applicable /etc/fstab entries, generally excluding entries marked noauto. This is different from a temporary mount, which normally disappears after unmounting or restarting unless it is also defined in /etc/fstab.

Mount troubleshooting

Mount troubleshooting symptoms
Symptom or errorLikely causeRecommended check or resolution
Mount point does not existThe target directory has not been createdRun sudo mkdir -p /path/to/mount-point, then retry.
Unknown or incorrect file system typeThe supplied type is wrong, the device has no supported file system, or support is unavailableInspect with blkid or lsblk; use automatic detection or the confirmed type.
umount reports that the target is busyA shell, application, open file, or nested mount is using itChange directory, inspect with fuser, lsof, and findmnt, then close or stop the user.
Persistent mount fails during boot or mount -aAn fstab field, UUID, type, mount point, or option is incorrectConfirm the UUID with blkid, check the directory and syntax, and run mount -a again.
The wrong disk mounts after hardware changesThe configuration depends on a device name such as /dev/sdb1Use a stable UUID= identifier in /etc/fstab.
Expected files appear to have disappearedA file system is mounted over the directoryUnmount it to reveal the original directory contents; do not assume the files were deleted.

Operational safety and exam notes

  • Use sudo or root privileges when mounting, unmounting, or editing /etc/fstab, unless an explicitly permitted configuration allows otherwise.
  • Unmount removable storage before physically removing it. This reduces the risk of incomplete writes and file system damage.
  • Use read-only mounting when the medium must not be changed or when investigating a potentially damaged file system.
  • Remember the spelling: the detach command is umount.
  • A mount point is a directory, not a copy of the device's contents.
  • For a busy mount, leave the directory first, then locate open files and processes.
  • For persistent mounts, prefer UUID= over volatile device names.
  • Always validate /etc/fstab with sudo mount -a before rebooting.

Complete practice workflow

Mount and unmount a partition

  1. Identify the partition and its file system type with blkid or lsblk.
  2. Create the target directory.
  3. Mount the partition.
  4. Verify the source, target, type, contents, and capacity.
  5. Leave the directory and unmount it before removing or maintaining the device.
sudo blkid
sudo mkdir -p /mnt/data
sudo mount /dev/sdb1 /mnt/data
findmnt /mnt/data
ls -la /mnt/data
df -h /mnt/data
cd /
sudo umount /mnt/data

Configure a persistent data mount

  1. Find the file system's UUID with sudo blkid.
  2. Create the mount point.
  3. Back up /etc/fstab.
  4. Add an entry with the correct UUID, mount point, type, options, dump field, and fsck pass.
  5. Run sudo mount -a and inspect errors before restarting.
  6. Verify with findmnt and df -h.
sudo blkid
sudo mkdir -p /mnt/data
sudo cp /etc/fstab /etc/fstab.backup
sudo mount -a
findmnt /mnt/data
df -h /mnt/data

For related storage administration, continue with mount and unmount file systems in Linux as a reference for the command patterns and safety checks covered here.