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/sdb1commonly 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, andISO 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/sdb1is the source device./mnt/datais the mount point, or target directory.ext4is the file system type.rw,relatimeare mount options. Here,rwpermits writing andrelatimecontrols 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.
| Command | Purpose | Example use |
|---|---|---|
mount | List currently mounted file systems | mount |
findmnt | Display a structured mount-tree view | findmnt /mnt/data |
df -h | Show mounted file system capacity and free space | df -h /mnt/data |
mount with a source and target | Perform a one-time manual mount | sudo mount /dev/sdb1 /mnt/data |
umount | Detach a mounted file system | sudo umount /mnt/data |
mount -a | Attempt applicable entries from /etc/fstab | sudo 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.
| Option | Effect | Appropriate use |
|---|---|---|
defaults | Uses the system's standard option set | Common starting point for persistent local mounts |
ro | Mounts read-only | Protected media or investigation of a file system |
rw | Mounts read-write | Normal storage that must be modified |
noauto | Does not mount the entry when mount -a runs | Removable media that should be mounted manually |
user | Allows a permitted non-root user to mount the file system | Some 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
ext4oriso9660. - The active options, such as
roorrw, match your intention. lsdisplays the expected contents anddf -hreports 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
| Field position | Field name | Purpose | Typical value |
|---|---|---|---|
| 1 | Source | Identifies the device or file system to mount | UUID=<filesystem-uuid> |
| 2 | Mount point | Directory where the file system becomes accessible | /mnt/data |
| 3 | File system type | Specifies the on-disk format | ext4 |
| 4 | Options | Controls mount behavior | defaults |
| 5 | Dump | Legacy backup utility field; commonly disabled | 0 |
| 6 | fsck pass | Controls file system check ordering at boot | 2 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 throughmount -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
| Symptom or error | Likely cause | Recommended check or resolution |
|---|---|---|
| Mount point does not exist | The target directory has not been created | Run sudo mkdir -p /path/to/mount-point, then retry. |
| Unknown or incorrect file system type | The supplied type is wrong, the device has no supported file system, or support is unavailable | Inspect with blkid or lsblk; use automatic detection or the confirmed type. |
umount reports that the target is busy | A shell, application, open file, or nested mount is using it | Change directory, inspect with fuser, lsof, and findmnt, then close or stop the user. |
Persistent mount fails during boot or mount -a | An fstab field, UUID, type, mount point, or option is incorrect | Confirm the UUID with blkid, check the directory and syntax, and run mount -a again. |
| The wrong disk mounts after hardware changes | The configuration depends on a device name such as /dev/sdb1 | Use a stable UUID= identifier in /etc/fstab. |
| Expected files appear to have disappeared | A file system is mounted over the directory | Unmount it to reveal the original directory contents; do not assume the files were deleted. |
Operational safety and exam notes
- Use
sudoor 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/fstabwithsudo mount -abefore rebooting.
Complete practice workflow
Mount and unmount a partition
- Identify the partition and its file system type with
blkidorlsblk. - Create the target directory.
- Mount the partition.
- Verify the source, target, type, contents, and capacity.
- 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
- Find the file system's UUID with
sudo blkid. - Create the mount point.
- Back up
/etc/fstab. - Add an entry with the correct UUID, mount point, type, options, dump field, and fsck pass.
- Run
sudo mount -aand inspect errors before restarting. - Verify with
findmntanddf -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.