How to Mount and Unmount File Systems in Linux
Learn how Linux mounts devices, how to inspect and safely unmount file systems, and how to configure persistent mounts with /etc/fstab.
Linux makes storage available by attaching a file system to the directory tree. This operation is called mounting. Once mounted, the files on a disk, partition, optical disc, or other storage device appear beneath a directory called a mount point.
A device and a mount point are different things. A device is the storage source, such as /dev/sdb1. A mount point is an existing directory, such as /mnt/data, where Linux attaches that file system.
How Linux Mounting Works
Linux uses one directory hierarchy that begins at /. Separate storage devices are not automatically separate directory trees from the user's perspective. Mounting connects a file system to a directory within that hierarchy.
- Device or partition: The storage source, commonly represented by a path such as
/dev/sdb1. - File system: The on-disk format, such as
ext4,xfs,vfat,exfat,ntfs, oriso9660. - Mount point: An existing directory where the file system becomes accessible.
For example, mounting /dev/sdb1 at /mnt/data makes the partition's contents available as /mnt/data/report.txt. The directory itself is not the disk; it is the location used to access the disk.
Any files that were already in a nonempty mount-point directory are hidden while another file system is mounted there. They become visible again after unmounting. For this reason, use an empty directory whenever possible.
View Currently Mounted File Systems
Run mount without arguments to list currently mounted file systems:
mount
A typical line contains the source device, the target directory, the file system type, and mount options. The general shape is similar to:
/dev/sdb1 on /mnt/data type ext4 (rw,relatime)
/dev/sdb1is the source device or partition./mnt/datais the target mount point.ext4is the file system type.rw,relatimeare mount options. Here,rwmeans read/write.
Modern tools often make inspection easier:
findmnt
df -h
lsblk -f
sudo blkid /dev/sdb1
findmntdisplays mounts in a tree-oriented format and can inspect a particular path.df -hreports used and available space in human-readable units.lsblk -flists disks and partitions with file system types, labels, UUIDs, and mount points.blkiddisplays identifying information such as a file system's UUID.
Manually Mount a File System
The general form of the mount command is:
sudo mount -t FILESYSTEM_TYPE DEVICE MOUNT_POINT
| Element | Purpose | Example |
|---|---|---|
mount | Attaches a file system, or displays current mounts when used without arguments. | mount |
-t file_system_type | Specifies the on-disk file system format. | -t ext4 |
device | Identifies the device or partition containing the file system. | /dev/sdb1 |
mount_point | Specifies the existing directory where the file system will appear. | /mnt/data |
The -t option is often optional for common file systems because Linux can usually detect the type:
sudo mount DEVICE MOUNT_POINT
Administrative privileges are normally required. The target directory must exist before mounting.
Create a Mount Point
Use mkdir -p to create the directory and any missing parent directories:
sudo mkdir -p /mnt/data
/mnt is a conventional location for temporary, manually managed mounts. /media is commonly used for removable media. Distribution and organization conventions can differ.
Mount a Disk Partition
After identifying the correct partition with lsblk -f, mount it without explicitly specifying the type:
sudo mkdir -p /mnt/data
sudo mount /dev/sdb1 /mnt/data
findmnt /mnt/data
If automatic detection is unsuitable, specify the known type:
sudo mount -t ext4 /dev/sdb1 /mnt/data
Do not guess the device name. Device names can change when disks are detected in a different order. Confirm the partition, label, type, and UUID first.
Mount an Optical Disc
An optical drive is often represented by /dev/sr0, and an optical file system commonly uses the iso9660 type:
sudo mkdir -p /mnt/cdrom
sudo mount -t iso9660 /dev/sr0 /mnt/cdrom
ls /mnt/cdrom
Optical media is normally read-only. When finished, unmount it before ejecting the disc.
Unmount a File System Safely
The command is spelled umount, not unmount. You can specify either the mount-point path or the device path:
sudo umount /mnt/data
sudo umount /dev/sdb1
Before unmounting:
- Leave the mounted directory in every shell. A shell whose current working directory is inside the mount can keep it busy.
- Save files and close applications using the mounted storage.
- Stop background jobs that read or write the mount.
- Unmount the file system, then safely disconnect or eject the device.
Handle a Busy Mount Point
If a process still has an open file or working directory there, umount may report that the target is busy. Identify users of the mount with:
sudo lsof +f -- /mnt/data
sudo fuser -vm /mnt/data
Close the reported application or change the working directory of the reported shell, then retry:
sudo umount /mnt/data
A busy mount should not be forcibly detached as a first response, because doing so can cause data loss or application errors.
Configure Persistent Mounts with /etc/fstab
/etc/fstab is the system configuration file for predefined file systems. Entries can be processed during boot, and mount -a attempts to mount eligible entries from this file.
Each entry has six standard fields separated by whitespace:
source mount_point type options dump fsck_pass
| Field | Meaning | Typical Example |
|---|---|---|
| Source device or UUID | The file system to mount. | UUID=7c2a... |
| Mount point | The existing directory where it will be attached. | /mnt/data |
| File system type | The on-disk format. | ext4 |
| Mount options | Comma-separated settings controlling mounting behavior. | defaults |
| Dump field | Legacy backup-dump setting; commonly 0. | 0 |
| fsck pass field | Order for file system checks at boot. Root commonly uses 1; other native file systems commonly use 2. | 2 |
Use UUIDs for Stable Device Identification
A UUID is a unique file system identifier. It is usually more stable than a path such as /dev/sdb1, because device names can change with hardware detection order.
Find the UUID and type:
sudo blkid /dev/sdb1
Create the mount point, back up the configuration, and edit the file:
sudo mkdir -p /mnt/data
sudo cp /etc/fstab /etc/fstab.backup
sudoedit /etc/fstab
Add a line like this, replacing the placeholder with the actual UUID:
UUID=<filesystem-uuid> /mnt/data ext4 defaults 0 2
Test the entry before rebooting:
sudo mount -a
findmnt /mnt/data
If mount -a reports an error, correct the entry before restarting the system.
Useful Mount Options
| Option | Purpose | Notes |
|---|---|---|
defaults | Uses a standard set of options. | A common starting point for local Linux file systems. |
ro | Mounts read-only. | Useful when writes must be prevented. |
rw | Mounts read/write. | Only works when the file system and device permit writing. |
nofail | Allows boot to continue if the device is absent or cannot be mounted. | Appropriate for nonessential removable or backup devices. |
noauto | Prevents the entry from being mounted automatically by mount -a or normal boot processing. | It can still be mounted explicitly. |
user | Allows a user to mount the file system under approved conditions. | Apply only when suitable for the local security policy. |
uid, gid, umask | Controls apparent ownership and permissions on file systems that do not store normal Linux ownership metadata. | Commonly relevant to formats such as vfat and some removable-media configurations, not generally needed for native ext4. |
An optional removable drive might use:
UUID=<filesystem-uuid> /mnt/backup ext4 defaults,nofail 0 2
Common Inspection and Management Commands
| Command | Use Case | Notes |
|---|---|---|
mount | List current mounts. | Also performs manual mounts with suitable arguments. |
findmnt | Inspect mounts in a tree-oriented format. | Use findmnt /mnt/data for one path. |
df -h | Check capacity and free space. | Uses human-readable units. |
lsblk -f | Discover disks, partitions, types, labels, UUIDs, and mount points. | Useful before choosing a device. |
blkid | Display file system identifiers and types. | Use sudo blkid DEVICE for a specific device. |
mount -a | Mount eligible entries from /etc/fstab. | Useful for testing edits without rebooting. |
umount | Detach a mounted file system. | Use a mount point or device path. |
Troubleshooting Mount Problems
Mount Point Does Not Exist
Create the missing directory and retry:
sudo mkdir -p /mnt/data
sudo mount /dev/sdb1 /mnt/data
Wrong Device or Partition
If expected files are missing or the device path fails, inspect the available storage:
lsblk -f
sudo blkid
Confirm the intended partition, label, UUID, and file system type before mounting.
Unknown or Incorrect File System Type
An unknown type or bad-superblock-style error can mean that the type was specified incorrectly, the required support is unavailable, or the file system has a problem. Check the actual type with lsblk -f or blkid. For common formats, retry without -t, or specify the correct type explicitly. Install the appropriate file system support package when your distribution requires one.
Permission Denied
Use sudo when administrative mounting is required. User-managed mounts should be enabled only through appropriate /etc/fstab options and local security policy. Options such as uid, gid, and umask may be needed for non-native file systems.
Boot Problems After Editing /etc/fstab
Check the UUID, mount-point directory, file system type, option spelling, and all six fields. Test with:
sudo mount -a
Use nofail for optional devices that may be disconnected, but do not use it to conceal an error in an essential mount.
Exam-Relevant Notes
- Mounting attaches a file system to an existing directory in the Linux directory hierarchy.
umountis the correct command name for detaching a file system.- The device, such as
/dev/sdb1, is not the same as its mount point, such as/mnt/data. mount -t TYPE DEVICE DIRECTORYis the explicit manual-mount form;-tcan often be omitted./etc/fstabhas six standard fields: source, mount point, type, options, dump, and fsck pass.mount -aprocesses eligible/etc/fstabentries.- UUIDs are generally preferable to volatile device names in persistent configurations.
- A busy mount point usually indicates an open file, active application, or shell whose working directory is inside the mount.
Related skills include identifying file types, managing file ownership, and understanding GPT partitions.