Linux mount Command Tutorial

Linux and Unix operating systems provide the mount command in order to attach file systems, disks, partitions, USB drive, cdrom, and even network shares into the local system. As a dynamic operation, we may also use the umount command in order to detach mounted devices.

List Mounted Devices/File Systems

Before mounting some devices or file systems it may be very helpful to list already mounted devices and file systems. By running the mount command without any option or parameter we can list already mounted devices or file systems.

$ mount

List Mounted Specific File Systems

Linux operating system may mount different types of file systems like ext3, ext4, btrfs, smb, etc. We can list only specified file systems which are mounted.

$ mount -t ext4

mount Command Syntax

The mount command has the following syntax which can be used to mount a file system or device.

  • OPTION is used to set different configurations like file system type etc.
  • DEVICE is the source device, partition, disk, etc which is mounted.
  • PATH is the destination path where the DEVICE is mounted.

Mount Disk

Let’s start with a simple example. In this example, we mount a device or partition named /dev/vda1 into the path /mnt/d . The mount operation is an administrator-level operation that requires root privileges. So we use the mount command with the sudo .

$ sudo mount /dev/vda1 /mnt/d

By default, the mount command detects the partition or disk file system type automatically and sets this configuration implicitly. But in some cases, this may not work or we may want to set the file system type explicitly. The -t option is used to set the file system type. In the following example, we mount the disk with the file system type ext4 .

$ sudo mount -t ext4 /dev/vda1 /mnt/d

Mount USB Drive

The mount command can be used to mount USB drives. First, we create the directory to mount. But alternatively, we can use the existing directory.

$ sudo mkdir /mnt/usbdrive

Now we assume the USB drive is named as /dev/sdb1 .

$ sudo mount /dev/sdb1 /mnt/usbdrive

Mount ISO File

ISO files are used to put multiple files into a single file which can be easily written into a CD or mounted. The mount command can be used to mount the ISO file. ISO file or file system is a bit different from other file systems which are called as loop device and the -o loop option should be provided. In the following example, we mount the ISO file named “ubuntu.iso” into the “/mnt/iso”.

$ sudo mount -o loop /home/ismail/ubuntu.iso /mnt/iso

Mount NFS

The NFS or Network File Share is a popular file system used in Linux and Unix operating systems. The NFS is used over a network where the file system is used via a network connection from other systems. By default the NFS libraries are not installed and can be installed like below.

Ubuntu, Debian, Mint, Kali:

$ sudo apt install nfs-common

CentOS, Fedora, RHEL:

$ sudo yum install nfs-utils

The NFS can be mounted by using the /etc/fstab file. Just open the fstab file with the following command.

# <file system>    <dir>           <type>   <options>   <dump>	<pass>  /media/nfs  nfs           defaults        0             0

After adding these lines we should call the mount command with the mount path like below to complete the mounting NFS file.

$ sudo mount /media/nfs

Mount Permanently

The /etc/fstab file is used to make mount operations permanent. The mount command parameters are stored inside this fstab file. The file system, path, type, options, dump and pass parameters are inserted into fstab file.

# <file system>    <dir>           <type>   <options>   <dump>	<pass>
/dev/sda1             /mount/d     ext4        defaults        0                 0

If you want to mount a recently added line we can use the mount command with the -a option like below.

$ sudo mount -a


The umount command is used to detach or unmount already mounted file systems or devices. The umount command provides safe removal of the file systems. If a file system is not unmounted properly some data loss or corruption may occur.

$ sudo umount /dev/sda1

Leave a Comment