How to Mount and Unmount File Systems in Linux

By 

•

Updated on

•

13 min read

How to Mount and Unmount File Systems in Linux

When you plug in a USB drive, add a new disk, or connect to a network share, its files do not appear anywhere until the device is mounted. In Linux and Unix-like systems, the mount command attaches file systems and removable devices such as USB drives to a mount point in the directory tree. The umount command detaches them when you are done.

This guide explains how to mount and unmount file systems in Linux using the mount and umount commands, including USB drives, ISO files, NFS shares, and persistent /etc/fstab entries.

How to List Mounted File Systems

When used without any argument, the mount command will display all currently attached file systems:

Terminal
mount

By default, the output will include all file systems including the virtual ones such as cgroup, sysfs, and others. Each line contains information about the device name, the directory to which the device is mounted, the type of the filesystem, and the mount options in the following form:

txt
device_name on directory type filesystem_type (options)

To display only certain file systems, use the -t option.

For example, to print only the ext4 partitions you would use:

Terminal
mount -t ext4

The findmnt command prints the same information as a tree. The output is easier to read than the plain mount output, and it shows how the mounts are nested:

Terminal
findmnt

To check a single mount point, pass it as an argument, for example findmnt /home.

Mounting a File System

To mount a file system in a given location (mount point), use the mount command in the following form:

txt
mount [OPTION...] DEVICE_NAME DIRECTORY

Once the file system is attached, the mount point becomes the root directory of the mounted file system.

Before you mount a file system manually, the target directory must already exist. This directory is called the mount point. To create a mount point, use mkdir:

Terminal
sudo mkdir -p /mnt/media

For example, to mount the /dev/sdb1 file system to the /mnt/media directory you would use:

Terminal
sudo mount /dev/sdb1 /mnt/media

Usually when mounting a device with a common file system such as ext4 or xfs, the mount command will auto-detect the file system type. However, some file systems are not recognized and need to be explicitly specified.

Use the -t option to specify the file system type:

txt
mount -t TYPE DEVICE_NAME DIRECTORY

To specify additional mount options , use the -o option:

txt
mount -o OPTIONS DEVICE_NAME DIRECTORY

Multiple options can be provided as a comma-separated list (do not insert a space after a comma).

You can get a list of all mount options by typing man mount in your terminal.

Mounting a File System using /etc/fstab

When providing just one parameter (either directory or device) to the mount command, it will read the content of the /etc/fstab configuration file to check whether the specified file system is listed or not.

If the /etc/fstab contains information about the given file system, the mount command uses the value for the other parameter and the mount options specified in the fstab file.

The /etc/fstab file contains a list of entries in the following form:

/etc/fstabtxt
[File System] [Mount Point] [File System Type] [Options] [Dump] [Pass]

Use the mount command in one of the following forms to attach a file system specified in the /etc/fstab file:

txt
mount [OPTION...] DIRECTORY
mount [OPTION...] DEVICE_NAME

For a full explanation of each field and the available mount options, see our guide on the /etc/fstab file .

Mounting a Drive Permanently

A file system mounted with the mount command stays mounted only until the next reboot. To mount a new disk or partition automatically at boot, add it to /etc/fstab. The steps below use the /dev/sdb1 partition and the /mnt/data mount point as an example.

  1. Find the UUID of the partition with blkid:

    Terminal
    sudo blkid /dev/sdb1
    output
    /dev/sdb1: UUID="5a1f3c2e-8b7d-4e6a-9c10-2f4b6d8e0a13" BLOCK_SIZE="4096" TYPE="ext4"

    Use the UUID in /etc/fstab, not the device name. Device names such as /dev/sdb1 can change when disks are added or removed, but the UUID stays the same. If you are not sure which device the drive uses, run lsblk -f to list all block devices with their file systems and UUIDs.

  2. Create the mount point:

    Terminal
    sudo mkdir -p /mnt/data
  3. Open the /etc/fstab file:

    Terminal
    sudo nano /etc/fstab

    Add the following line at the end of the file, replacing the UUID and the file system type with your own values:

    /etc/fstabini
    UUID=5a1f3c2e-8b7d-4e6a-9c10-2f4b6d8e0a13  /mnt/data  ext4  defaults,nofail  0  2

    The nofail option lets the system boot normally when the drive is not connected. The last field, 2, tells fsck to check the file system after the root partition.

  4. Reload the systemd configuration and test the entry:

    Terminal
    sudo systemctl daemon-reload
    sudo findmnt --verify
    sudo mount -a

    The findmnt --verify command checks /etc/fstab for parsing errors and verifies whether its entries are usable. The mount -a command then mounts entries that are not already mounted and do not use the noauto option; it ignores swap entries. If both commands finish without errors, the system will attempt to mount the drive at every boot.

Systemd generates its mount units from /etc/fstab. If you skip the reload, mount prints a hint telling you that systemd still uses the old version of the file.

Warning
A broken /etc/fstab entry can stop the system from booting normally. Validate the file with sudo findmnt --verify before you reboot. For a new unmounted entry that does not use noauto, run sudo mount -a to confirm that it mounts successfully.

Mounting USB Drive

On most modern Linux distributions, USB drives will auto-mount when you plug them in, but sometimes you may need to manually mount the drive.

To manually mount a USB device, perform the following steps:

  1. Create the mount point:

    Terminal
    sudo mkdir -p /media/usb
  2. To find the device name and file system type, use lsblk -f:

    Terminal
    lsblk -f

    The FSTYPE column shows the file system type. After identifying the partition, you can run sudo blkid DEVICE to confirm its type and UUID.

  3. Assuming that the USB drive uses the /dev/sdd1 device, mount it to the /media/usb directory:

    Terminal
    sudo mount /dev/sdd1 /media/usb

Most current Linux distributions can mount exFAT USB drives without extra drivers. If you need to format or repair an exFAT drive, see the exFAT mount guide for exfatprogs usage.

Mounting ISO Files

You can mount an ISO file using the loop device, which is a special pseudo-device that makes a file accessible as a block device.

  1. Start by creating the mount point. It can be any location you want:

    Terminal
    sudo mkdir /media/iso
  2. Mount the ISO file to the mount point by typing the following command:

    Terminal
    sudo mount /path/to/image.iso /media/iso -o loop

    Replace /path/to/image.iso with the path to your ISO file.

For instructions on mounting read-only images as a regular user with udisksctl, working with other disk image formats, or extracting an image without mounting it, see the dedicated guide on how to mount an ISO file .

Mounting NFS

To mount an NFS share , you will need to have the NFS client package installed on your system.

  • Install NFS client on Ubuntu, Debian, and Derivatives:

    Terminal
    sudo apt install nfs-common
  • Install NFS client on Fedora, RHEL, and Derivatives:

    Terminal
    sudo dnf install nfs-utils

Use the steps below to mount a remote NFS directory on your system:

  1. Create a directory to serve as the mount point for the remote filesystem:

    Terminal
    sudo mkdir /media/nfs
  2. Generally, you will want to mount the remote NFS share automatically at boot. To do so, open the /etc/fstab file with your text editor :

    Terminal
    sudo nano /etc/fstab

    Add the following line to the file, replacing remote.server:/dir with the NFS server IP address or hostname and the exported directory:

    /etc/fstabini
    # <file system>    <dir>       <type>   <options>   <dump>  <pass>
    remote.server:/dir /media/nfs  nfs      defaults    0       0
  3. Mount the NFS share by running the following command:

    Terminal
    sudo mount /media/nfs

Mounting a Directory with a Bind Mount

Sometimes you need to make the contents of one directory available at another location without copying any data. A bind mount attaches an existing directory to a second mount point, so both paths show the same files.

Use the --bind option followed by the source and target directories:

Terminal
sudo mount --bind /source/dir /target/dir

Both directories must already exist. After the bind mount, any change made under one path is visible under the other, because they point to the same data.

To make a bind mount persistent, add an entry to /etc/fstab using the bind option:

/etc/fstabini
/source/dir  /target/dir  none  bind  0  0

Remounting a File System

To change the options of a file system that is already mounted, use the remount option. You do not need to unmount the file system first. For example, to remount the root file system in read-write mode:

Terminal
sudo mount -o remount,rw /

This is a common step in recovery mode, where the root file system is mounted read-only. In the same way, -o remount,ro switches a mounted file system to read-only mode.

Unmounting a File System

To detach a mounted file system, use the umount command followed by its mount point. Most unmount operations require root privileges. For example, to unmount /mnt/media, run:

Terminal
sudo umount /mnt/media

Specifying the device name may also work, but that form is obsolete and can fail when the same device is mounted in more than one location. Prefer the mount point path.

If the file system is in use, the umount command will fail to detach it and print a target is busy error. In those situations, you can use the fuser command to find out which processes are accessing the file system:

Terminal
sudo fuser -vm /mnt/media

The verbose output shows the processes and users accessing the mounted file system. Once you determine the processes, you can stop them and retry the unmount.

Lazy Unmount

Use the -l (--lazy) option to detach a busy file system from the directory tree right away. The kernel cleans up the remaining references once the file system is no longer busy:

Terminal
sudo umount -l /mnt/nfs

Lazy unmount is intended primarily to prevent hangs caused by an unreachable network share. Existing references remain active until they close, the share cannot be remounted, and a reboot should follow soon. Do not use it as a shortcut for an ordinary target is busy error.

Force Unmount

Use the -f (--force) option to force an unmount. This option is meant for an unreachable NFS system:

Terminal
sudo umount -f /mnt/nfs

Any writes that have not reached the server may be lost. The command can still hang on some NFS mounts. If it does, use a lazy unmount instead.

Recursive Unmount

When other file systems are mounted under a directory, use the -R (--recursive) option to unmount the directory and everything mounted below it:

Terminal
sudo umount -R /mnt/data

The recursive unmount works only with a mount point path, not with a device name.

Quick Reference

For a printable quick reference, see the mount cheatsheet .

CommandDescription
mountList all mounted file systems
mount -t ext4List mounted file systems of a specific type
findmntShow mounted file systems as a tree
sudo mount DEVICE DIRMount a device to a directory
sudo mount -t TYPE DEVICE DIRMount with an explicit file system type
sudo mount -o OPTIONS DEVICE DIRMount with specific options
sudo mount DIRMount using /etc/fstab entry
sudo mount -aMount unmounted /etc/fstab entries except noauto and swap
sudo blkid /dev/sdb1Show the UUID and file system type of a partition
sudo mount -o remount,rw /Remount the root file system read-write
sudo mount /dev/sdd1 /media/usbMount a USB drive
sudo mount /path/to/image.iso /media/iso -o loopMount an ISO file
sudo mount --bind /source/dir /target/dirBind mount one directory to another
sudo umount DIRECTORYUnmount by mount point
sudo umount -l DIRECTORYLazy unmount an unreachable network share
sudo umount -f DIRECTORYForce unmount an unreachable NFS share
sudo umount -R DIRECTORYUnmount a directory and all mounts below it
sudo fuser -vm DIRECTORYShow processes and users accessing a mount point
lsblk -fList block devices, file system types, and mount points

Troubleshooting

“must be superuser to use mount”
The mount command requires root privileges. Prefix the command with sudo, or add the device to /etc/fstab with the user option to allow non-root mounts.

“target is busy” when unmounting
A process is still accessing the file system. Run sudo fuser -vm DIRECTORY to identify the processes, then stop them before retrying sudo umount DIRECTORY. A shell whose current directory is inside the mount point also keeps it busy, so cd out of it first.

“wrong fs type, bad option, bad superblock”
The full message ends with “missing codepage or helper program, or other error”. The mount command could not attach the device with the given type or options. Check that the -t value matches the real file system, for example sudo mount -t ext4 /dev/sdb1 /mnt/data, and run lsblk -f to confirm it. If the type is correct, the file system may be damaged. Unmount it and check it with fsck .

“bad option; for several filesystems (e.g. nfs, cifs)”
This error appears when you mount a network share and the client package is missing. Install nfs-common (Ubuntu, Debian) or nfs-utils (Fedora, RHEL) for NFS shares, and cifs-utils for Windows (SMB) shares .

Mount does not persist after reboot
Mounts made with mount are not persistent. To mount a file system automatically at boot, add an entry to /etc/fstab as shown in the Mounting a Drive Permanently section.

“can’t read superblock” on a USB drive
The drive may use a file system that is not available on the running system, or the file system may be damaged. For exFAT drives, current distributions usually mount them natively; install exfatprogs if you need repair tools, then retry the mount.

FAQ

What is the difference between mount and umount?
mount attaches a file system to a directory in the tree, making its contents accessible at that path. umount detaches it, and the directory shows its original contents again.

Why is the command umount and not unmount?
The command has been spelled umount since early Unix, a historical convention, not a typo.

How do I make a mount persistent across reboots?
Add an entry to /etc/fstab. The format is: DEVICE MOUNTPOINT FSTYPE OPTIONS DUMP PASS. After editing the file, run sudo findmnt --verify to validate it. Use sudo mount -a to try new unmounted entries that do not use noauto without rebooting.

What is a mount point in Linux?
A mount point is a directory where a file system is attached and made accessible. After mounting, the mounted file system appears under that directory path.

How do I find the device name of a connected drive?
Run lsblk -f to list block devices with their file system types and mount points. After identifying the device, use sudo blkid DEVICE to confirm its type and UUID.

Can I mount a directory to another directory?
Yes, using a bind mount: sudo mount --bind /source/dir /target/dir. This makes the contents of the source directory accessible at the target path without duplicating any data.

Conclusion

The mount command is the primary tool for attaching file systems in Linux, from local partitions and USB drives to ISO images and NFS shares. Use /etc/fstab to make mounts persistent across reboots, and umount to safely detach them when done. For NFS-specific setup, see the NFS mount guide .

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 1000+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page