Linux mount Command with Examples {+How to Unmount a File System} (2023)


The Linux file system hierarchy is arranged in a tree, with the file system starting from the root directory (/). All other child file systems branch out from the root directory.

The mount command allows users to mount, i.e., attach additional child file systems to a particular mount point on the currently accessible file system. The command passes the mount instructions to the kernel, which completes the operation.

This tutorial will teach you the basics of attaching file systems in Linux using the mount command.

Linux mount Command with Examples {+How to Unmount a File System} (1)


  • A system running Linux.
  • Access to the terminal (Ctrl + Alt + T).
  • A user account with administrator privileges.

Linux mount Command Syntax

The standard mount command syntax is:

mount -t [type] [device] [dir]

The command instructs the kernel to attach the file system found on [device] at the [dir] directory. The -t [type] option is optional, and it describes the file system type (EXT3, EXT4, BTRFS, XFS, HPFS, VFAT, etc.).

If the destination directory is omitted, it mounts the file systems listed in the /etc/fstab file.

While the file system is mounted, the previous contents, owner, and mode of the [dir] directory are invisible, and the [dir] pathname refers to the file system root.

Exit Status

The mount command returns one of the following values that indicate the process completion status:

  • 0. Success.
  • 1. Incorrect command invocation or insufficient permissions.
  • 2. System error.
  • 4. Internal mount bug.
  • 8. Operation interrupted by user.
  • 16. Issues with writing or locking the /etc/mtab file.
  • 32. Mount failure.
  • 64. At least one mount operation succeeded, but not all.

Note: See how to create a partition in Linux or how to delete a partition in Linux.

mount Command Options

The mount command options further specify file system types, mount location, and type. The following table shows the most common mount options:

(Video) mounting and unmounting disks/partitions - Linux Command Line tutorial for forensics - 15

-aMounts all file systems listed in /etc/fstab.
-FForks a new incarnation of mount for each device. Must be used in combination with the -a option.
-hDisplays the help file with all command options.
-lLists all the file systems mounted and adds labels to each device.
-L [label]Mounts the partition with the specified [label].
-MMoves a subtree to another location.
-O [opts]Used in combination with -a, it limits the file system set that -a applies to. The [opts] refers to options specified in the options field of the /etc/fstab file. The command accepts multiple options specified in a comma-separated list (without spaces).
-rMounts the file system in read-only mode.
-RRemounts a subtree in a different location, making its contents available in both places.
-t [type]Indicates the file system type.
-TUsed to specify an alternative /etc/fstab file.
-vMounts verbosely, describing each operation.
-VDisplays the program version information.

Run the man mount command for a complete list of options, syntax forms, and filesystem-specific mount options.

Linux mount Command Examples

Outlined below are the most common use cases of the mount command.

List Mounted File Systems

Run the mount command without any options to display all currently mounted file systems. The output also displays the mount points and mount options.

For example:

Linux mount Command with Examples {+How to Unmount a File System} (2)

List Specific File Systems

The -t option allows users to specify which file systems to display when running the mount command. For example, to show only ext4 file systems, run the following command:

mount -t ext4
Linux mount Command with Examples {+How to Unmount a File System} (3)

Mount a File System

Mounting a file system requires the user to specify the directory or mount point to which the file system will be attached. For example, to mount the /dev/sdb1 file system to the /mnt/media directory, run:

sudo mount /dev/sdb1 /mnt/media

To specify additional file system-specific mount options, pass the -o flag followed by the options before the device name. Use the following syntax:

mount -o [options] [device] [dir]

See the man page or help file for a complete list of available options.

Mount File System with /etc/fstab

The /etc/fstab file contains lines describing the mount location of system devices and the options they are using. Generally, fstab is used for internal devices, such as CD/DVD devices, and network shares (samba/nfs/sshfs). Removable devices are typically mounted by the gnome-volume-manager.

Providing only one parameter (either [dir] or [device]) causes mount to read the contents of the /etc/fstab configuration file to check if the specified file system is listed in it. If the given file system is listed, mount uses the value for the missing parameter and the mount options specified in the /etc/fstab file.

The defined structure in /etc/fstab is:

<file system> <mount point> <type> <options> <dump> <pass>

The following screenshot shows the contents of the /etc/fstab file:

Linux mount Command with Examples {+How to Unmount a File System} (4)

To mount a file system specified in the /etc/fstab file, use one of the following syntaxes:

(Video) mount | umount | fdisk | mkfs | Linux Commands mount, umount, fdisk & mkfs | Full Details

mount [options] [dir]
mount [options] [device]
  • For [dir], specify the mount point.
  • For [device], specify the device identifier.

See the mount command man page or run man mount for a comprehensive list of file system-specific and file system-independent options.

Mount USB Drive

Modern Linux distributions automatically mount removable drives after insertion. However, if the automatic mount fails, follow the steps below to mount the USB drive manually:

1. Create a mount point using the mkdir command:

mkdir /media/usb-drive

2. Find the USB device and file system type. Run:

fdisk -l
Linux mount Command with Examples {+How to Unmount a File System} (5)

3. Using the device identifier from fdisk output, mount the USB drive using the following syntax:

sudo mount [identifier] /media/usb-drive

For example, if the device is listed as /dev/sdb1, run:

sudo mount /dev/sdb1 /media/usb-drive

Mount a CD-ROM

Being a removable device, Linux automatically mounts CD-ROMs as well. However, if mounting fails, mount a CD-ROM manually by running:

mount -t iso9660 -o ro /dev/cdrom /mnt

Make sure that the /mnt mount point exists for the command to work. If it doesn't, create one using the mkdir command.

iso9660 is the standard file system for CD-ROMs, while the -o ro options cause mount to treat it as a read-only file system.

Mount ISO Files

Mounting an ISO file requires mapping its data to a loop device. Attach an ISO file to a mount point using a loop device by passing the -o loop option:

sudo mount /image.iso /media/iso-file -o loop

Mount an NFS

A Network File System (NFS) is a distributed file system protocol for sharing remote directories over a network. Mounting an NFS allows you to work with remote files as if they were stored locally.

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

Important: Mounting an NFS requires having the NFS client package installed. See how to install the NFS server on Ubuntu.

(Video) How to Mount and Unmount a FileSystem in Linux(RedHat)

1. Create a mount point using the mkdir command:

sudo mkdir /media/nfs

2. Mount the NFS share by running:

sudo mount /media/nfs

3. To automatically mount the remote NFS share at boot, edit the /etc/fstab file using a text editor of your choice:

sudo vi /etc/fstab

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

remote.server:/dir /media/nfs nfs defaults 0 0

Note: See how to create and use NFS Docker volumes.

Non-Superuser Mounting

Although only a superuser can mount file systems, file systems in the /etc/fstab file containing the user option can be mounted by any system user.

Edit the /etc/fstab file using a text editor and under the <options> field specify the user option. For example:

/dev/cdrom /cd iso9660 ro,user,noauto,unhide

Adding the line above to /etc/fstab allows any system user to mount the iso9660 file system from a CD-ROM device.

Specifying the users option instead of user allows any user to unmount the file system, not only the user that mounted it.

Move a Mount

If you decide to move a mounted file system to another mount point, use the -M option. The syntax is:

mount --move [olddir] [newdir]

For [olddir], specify the current mount point. For [newdir], specify the mount point to which you want to move the file system.

Moving the mounted file system to another mount point causes its contents to appear in the [newdir] directory but doesn't change the physical location of the files.

How to Unmount a File System

To unmount, i.e., detach an attached file system from the system tree, use the umount command. Detach the file system by passing either its mount point or the device name.

The syntax is:

(Video) Linux 101: How to use the mount command

umount [dir]


umount [device]

For example, to detach a USB device listed as /dev/sdb1, run:

umount /dev/sdb1

While busy with open files or ongoing processes, a file system cannot be detached, and the process fails. If you aren't sure what's using the file system, run the fuser command to find out:

fuser -m [dir]

For [dir], specify the file system mount point. For example:

fuser -m /media/usb-drive
Linux mount Command with Examples {+How to Unmount a File System} (6)

The output lists the PIDs of processes currently accessing the device. Stop the processes and unmount the file system.

Note: Learn how to list the running processes in Linux.

Lazy Unmount

If you don't want to stop the processes manually, use the lazy unmount, which instructs the unmount command to detach the file system as soon as its activities stop. The syntax is:

umount --lazy [device]

Forced Unmount

The -f (--force) option allows users to force an unmount. However, be cautious when force unmounting a file system as the process may corrupt the data on it.

The syntax is:

umount -f [dir]


This tutorial showed how to use the mount command to attach various file systems to the directory tree and provided other practical examples. The tutorial also showed how to use the umount command to detach a file system.

Next, we recommend you to read about the fsck command for checking and repairing file systems, or see how to check disk space in Linux.


How to unmount filesystem in Linux? ›

On Linux, the easiest way to unmount drives on Linux is to use the “umount” command. Note : the “umount” command should not be mispelled for “unmount” as there are no “unmount” commands on Linux.

How do I unmount and mount in Linux? ›

Mounting and unmounting media using Linux
  1. Type cd and then press Enter.
  2. Type one of the following commands: If the medium to be unmounted is a CD, type umount /mnt/cdrom. and then press Enter. If the medium to be unmounted is a diskette, type umount /mnt/floppy. and then press Enter.

Which command is used to unmount a filesystem in Linux? ›

The umount command unmounts a previously mounted device, directory, file, or file system. Processing on the file system, directory, or file completes and it is unmounted. Members of the system group and users operating with root user authority can issue any umount command.

What is mount in Linux with example? ›

How do I unmount all filesystems? ›

Use umount command to unmount any mounted filesystem on your system. Run umount command with disk name or mount point name to unmount currently mounted disk.

What is mount unmount system? ›

The mount command mounts a storage device or filesystem, making it accessible and attaching it to an existing directory structure. The umount command "unmounts" a mounted filesystem, informing the system to complete any pending read or write operations, and safely detaching it.

What is Linux MT command? ›

Description. The mt command gives subcommands to a streaming tape device. If you do not specify the -f flag with the TapeName parameter, the TAPE environment variable is used. If the environment variable does not exist, the mt command uses the /dev/rmt0.

Which command is used to mount? ›

mount command is used to mount the filesystem found on a device to big tree structure(Linux filesystem) rooted at '/'. Conversely, another command umount can be used to detach these devices from the Tree. These commands tells the Kernel to attach the filesystem found at device to the dir.

What is unmount drive Linux? ›

Unmounting a drive in Linux using the umount command

Unmounting a drive is handled via the umount command and when invoked it safely removes the drive from the system, enabling us to pull the drive and use it in another machine.

How do I unmount a file? ›

Select the drive used for the ISO file and click or tap the Manage tab on the ribbon. Then, click or tap Eject. You can also unmount the ISO file by right-clicking or pressing-and-holding the drive of your ISO file, and then clicking or tapping Eject in the contextual menu.

How do I unmount a disk? ›

Unmount a disk member of a set
  1. In the Disk Utility app on your Mac, select the disk set that you want to unmount in the sidebar.
  2. Click the Unmount button in the toolbar or beside the disk set name.
  3. Disconnect the disk member that you want to unmount.

How do I mount a file system in Linux? ›

How to Mount File Systems on Linux
  1. This command is only necessary if the /mnt/floppy directory doesn't already exist: mkdir /mnt/floppy.
  2. Use mount with the -t flag (short for “type”) to specify MSDOS as the file system: mount -t msdos /dev/fd0 /mnt/floppy.
Sep 15, 2022

What is an example of mounting? ›

Mounting Sentence Examples

The officer, mounting his horse, rode off to someone else. The object-glass is by Clark, the mounting by the Repsolds. Mounting, she grabbed his waist as he took off again.

How do you create a mount in Linux? ›

Mounting ISO Files
  1. Start by creating the mount point, it can be any location you want: sudo mkdir /media/iso.
  2. Mount the ISO file to the mount point by typing the following command: sudo mount /path/to/image.iso /media/iso -o loop. Don't forget to replace /path/to/image. iso with the path to your ISO file.
Aug 23, 2019

Where are filesystems mounted in Linux? ›

The mount Command

The Linux root filesystem is mounted on the root directory (/) very early in the boot sequence. Mounting of filesystems during the startup process is managed by the /etc/fstab configuration file.

How to mount a folder in Linux? ›

Mounting a Shared Folder on a Linux Computer
  1. Open a terminal with root privileges.
  2. Run the following command: mount <NAS Ethernet Interface IP>:/share/<Shared Folder Name> <Directory to Mount> Tip: ...
  3. Specify your NAS username and password.

How do I mount a file system? ›

Mounting filesystems isn't complicated. Usually, it takes only two steps: Create the mount point (create a directory using the mkdir command)
3. Mounting Filesystems
  1. 3.1. USB Drive/Stick. ...
  2. 3.2. ISO Files. ...
  3. 3.3. Samba Share. ...
  4. 3.4. NFS. ...
  5. 3.5. Commonly Used mount -o Options. ...
  6. 3.6. The /etc/fstab File.
Oct 10, 2020

What does mounting and unmounting a disk mean? ›

(1) To disconnect a disk drive or optical disc from a computer. When a user selects "eject" to evacuate an optical disc from the computer, the operating system unmounts the medium. Contrast with mount. (2) To remove a disk or tape cartridge from the drive.

What does it mean to mount and unmount a disk? ›

When a disk is mounted, it is active and the computer can access its contents. Since unmounting a disk prevents the computer from accessing it, there is no risk of the disk being disconnected in the middle of a data transfer.

How do I force unmount a mount point in Linux? ›

Once a file system is mounted, you can use the umount command (without an “n”) to unmount the file system. You can unmount the file system by using umount with the device or the mount point. In order to unmount the file system, no application or user may use the file system.

What is the correct syntax of mount command? ›

Use the TSO MOUNT command to make a connection between a mount point on your local file system and one or more files on a remote AIX, UNIX, , or other file system. The MOUNT command can only be used by a z/OS superuser.

How do I see mounts in Linux? ›

The command findmnt lists all mount points. To do this the findmnt reads files /etc/fstab, /etc/fstab. d, /etc/mtab or /proc/self/mountinfo.

Why do we use mount command? ›

The mount command allows users to mount, i.e., attach additional child file systems to a particular mount point on the currently accessible file system. The command passes the mount instructions to the kernel, which completes the operation.

How do I mount a disk command? ›

To mount a drive in an empty folder by using the Windows interface
  1. In Disk Manager, right-click the partition or volume that has the folder in which you want to mount the drive.
  2. Click Change Drive Letter and Paths and then click Add.
  3. Click Mount in the following empty NTFS folder.
Jun 17, 2021

How do I use the mount command in Unix? ›

The mount command serves to attach the file system found on some device to the big file tree. Conversely, the umount(8) command will detach it again. mount -t type device dir This tells the kernel to attach the file system found on device (which is of type type) at the directory dir.

How do I unmount and delete a partition in Linux? ›

Deleting a partition in Linux requires selecting the disk containing the partition and using the fdisk command-line utility to delete it.
Delete a Partition in Linux
  1. Step 1: List Partition Scheme. ...
  2. Step 2: Select the Disk. ...
  3. Step 3: Delete Partitions. ...
  4. Step 4: Verify Partition Deletion. ...
  5. Step 5: Save Changes and Quit.
Sep 30, 2020

How do I unmount a shared file in Linux? ›

To force unmount a CIFS share in Linux, do the following.
  1. Open your favorite terminal app.
  2. Type the following command: sudo umount -a -t cifs -l , then supply your password.
  3. If the sudo command is not available in your environment, switch to root with the su command, and then issue the command umount -a -t cifs -l.
Oct 5, 2018

How do I see unmounted devices in Linux? ›

How to show Unmounted drives using the “lsblk” command: The “lsblk” command-line tool is used to list down information about all the present or defined block devices.

How do I unmount an ISO file? ›

Unmounting an ISO File
  1. Open File Station.
  2. On the left panel, locate the mounted ISO file.
  3. Right-click the file and then select Unmount. A confirmation message appears.
  4. Click Yes. File Station unmounts the ISO file and displays a confirmation message.
  5. Click OK.

How to remove mounted ISO in Linux? ›

To unmount a mounted file system, use the umount command. Note that there is no “n” between the “u” and the “m”—the command is umount and not “unmount.” You must tell umount which file system you are unmounting. Do so by providing the file system's mount point.

How do I unmount a drive in command prompt? ›

Safely Remove or Eject a Disk Using the Command Line
  1. On command prompt, type "diskpart" and wait for the new prompt, then type "list volume". ...
  2. Type "select volume <number>", where <number> is the number of your USB storage.
  3. Then, type "remove all dismount".

What is the mounting of file system answer? ›

Mounting a file system attaches that file system to a directory (mount point) and makes it available to the system. The root ( / ) file system is always mounted. Any other file system can be connected or disconnected from the root ( / ) file system.

What is a mount in file system? ›

In computers, to mount is to make a group of files in a file system structure accessible to a user or user group. In some usages, it means to make a device physically accessible.

What is mount in file system? ›

Mounting is a process by which a computer's operating system makes files and directories on a storage device (such as hard drive, CD-ROM, or network share) available for users to access via the computer's file system.

What are the two types of mounts? ›

There are two major types of mounts for astronomical telescopes: Altazimuth and Equatorial. Altazimuth (sometimes called alt-az) is the simplest type of mount with two motions, altitude (vertical) and azimuth (horizontal): thus the name Altazimuth.

What is mounting give example of mounting media? ›

What are mounting media? Mounting medium is the medium that your sample is in while it is being imaged on the microscope. The simplest type of mounting medium is air, or a saline-based buffered solution, such as PBS.

What do you mean by mounting? ›

: rise, ascend. : to increase in amount or extent. expenses began to mount. 3. : to get up on something above the level of the ground.

How remove filesystem a disk in Linux? ›

Use the rmfs command to remove an existing file system from the system. When the rmfs command completes, the character device entry from /dev is deleted, and the mount point directory where the file system had been mounted is removed on all file modules.

How do I unmount NFS filesystem in Linux? ›

To remove a predefined NFS mount by editing the /etc/filesystems file:
  1. Enter the command: umount /directory/to/unmount .
  2. Open the /etc/filesystems file with your favorite editor.
  3. Find the entry for the directory you just unmounted, and then delete it.
  4. Save and close the file.

How do I unmount a disk drive? ›

Safely Unmount SD Card in Android

Within Settings, tap the Storage button. Scroll down the Storage screen, and near the bottom, you'll find what we're looking for. Tap the Unmount SD Card button. And then tap OK to confirm in the pop-up that appears.

What are ways to remove a file in Linux? ›

Use the rm command to remove files you no longer need. The rm command removes the entries for a specified file, group of files, or certain select files from a list within a directory. User confirmation, read permission, and write permission are not required before a file is removed when you use the rm command.

How do I remove filesystem from partition? ›

to destroy a filesystem I used "wipefs -a /dev/xda?" and "wipefs -a /dev/xda". This will wipe the filesystem, partition, raid and disk labels from the disk.

What is remove directory command in Linux? ›

To permanently remove a directory in Linux, use either the rmdir or rm command:
  1. Use the rmdir or rm -d command to remove empty directories.
  2. Use the rm -r command to remove non-empty directories.


1. What is mounting and unmounting in Linux | mount and umount commands in linux
(Student Globe)
2. Linux Crash Course - Formatting & Mounting Storage Volumes
(Learn Linux TV)
3. Learn to mount and unmount a USB using command line in Linux
(Code Shock)
4. Linux Tutorial 63 - mount command in linux | umount command in linux | Mount and Unmount Partitions
(Dikshant (DevOps Guy))
5. Mount and unmount USB devices in the linux terminal! || mount, umount commands Linux!
(Merge To Master)
6. 16.2 mounting and unmounting of filesystem
Top Articles
Latest Posts
Article information

Author: Prof. Nancy Dach

Last Updated: 09/16/2022

Views: 6060

Rating: 4.7 / 5 (77 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Prof. Nancy Dach

Birthday: 1993-08-23

Address: 569 Waelchi Ports, South Blainebury, LA 11589

Phone: +9958996486049

Job: Sales Manager

Hobby: Web surfing, Scuba diving, Mountaineering, Writing, Sailing, Dance, Blacksmithing

Introduction: My name is Prof. Nancy Dach, I am a lively, joyous, courageous, lovely, tender, charming, open person who loves writing and wants to share my knowledge and understanding with you.