How do I mount a drive in Ubuntu?

In the file sharing system of computing, mounting generally refers to making the file system available for a group of users. Accessing the data from other than drives of the PC (external drives, USB sticks) needs to be formatted according to the filesystem of the computer. Microsoft provides the automatic mounting of external storage devices and the users can access the data, however, Linux does not provide such an option to mount the drives automatically. However, this can be done manually too; our today’s guide will demonstrate the step-by-step process of mounting an external drive in Ubuntu:

How to mount a drive in Ubuntu

To mount the devices, you must go for the partition method that is described here step by step. You have to create the partition of the storage device (external hard disk or USB pen drive); to do so, follow the steps that are elaborated below:

Step 1: Check the path of the inserted storage device : Insert the external storage device (partitions or externally inserted devices) in your Ubuntu system and you must check that by using the following command:

$ sudo fdisk -l

At this stage, sometimes the drive won’t mount and will show partition errors: so, you must follow the step 2 to get rid of these errors, otherwise you can skip step 2 and jump to step 3:

Note: Linux OS recognizes the devices by assigning them names, the categorization of those names is described below:

Floppy disks: The floppy disks are recognized as the “fd” keyword, and if one floppy disk is detected, then it would be “fd1”; for a second, it would be “fd2” and so on for other floppy disks, “fd3”,… “fdn”.

Hard disks: Like the floppy disks, the hard disks are represented by “sda”, “sdb”, and so on. “sda” is used to represent the first hard disk detected, “sdb” for the second hard disk, and the sequence continues.

Step 2: Partition the external storage device : This step is quite comprehensive, and the user must follow them carefully as the size and type of partition will also be specified here by keeping the terminal in a parted environment.

As discussed above the mounting will display errors, so for that you have to partition it first:

$ sudo parted /dev/sdb

After executing the above command, within the environment of the command, you should follow the command mentioned below to allow greater than 2GB’s partitions.

$ mklabel gpt

Within this partition environment, you can also set the size, it depends on the user’s choice to allocate the space, as in our case we are limiting the partition from GB to 3GB by using the following command: you just have to change the upper bound to have a partition of greater or lesser size.

$ mkpart primary 0GB 3GB

Once you have successfully attempted the above steps of partition; now you must assign a file system for the newly made partition. However, you can proceed only if you leave the parted environment; just type “quit” in the terminal and hit enter the terminal will come out of that environment:

$ quit

The final step to active the partition is assigning file format for the new partition; so, you have to choose the file system (.ext4) of the newly made partition by using the below-mentioned command:

$ sudo mkfs.ext4 /dev/sdb

Step 3: Mount Process : Once the partition step is performed, you can mount the drive; before this, you should create a new directory in the “/mnt/” directory where the drives are usually mounted in Ubuntu. Make new directory in “/mnt/” by using the terminal as mentioned below:

$ sudo mkdir /mnt/sdb

Once the directory is created, you can mount the inserted drive by using the command written below:

$ sudo mount /dev/sdb /mnt/sdb

How to permanently mount the drive

However, it is observed that the below command will temporarily mount the drive, whenever you will restart the system, you must mount it again. To avoid such happening you must edit the file system table “fstab” by using the nano editor:

$ sudo nano /etc/fstab

And after getting the file in editor you must add the following data in file system table to enable the automatic mount process:

Path (hard drive): “/dev/sdb”

Destination (mounted drive): “/mnt/sdb”

Format of partition: “ext4”

/dev/sdb    /mnt/sdb     ext4      defaults        0             0

How to check the drive is mounted or not

You can check the mounted drive by using the command mentioned below: you can specify the directory name (sdb in our case) after “grep” to get the pointed information; otherwise, the mount command will list down all the mounted drives and partitions in your system:

$ sudo mount | grep sdb

How to unmount a mounted drive in Ubuntu

If you want to unmount the drive, you can use any of the command stated below:

$ sudo umount -l /dev/sdb


The command stated below can also work for unmounting the drive and you must specify the correct directory name (sdb in our case):

$ sudo umount /dev/sdb


In computing, several operating systems offer an automatic mounting of externally added storage devices; however, Linux OS does not provide this option as an automatic accessibility that means if the drive is opted for mount in Ubuntu, you will face execution errors. In this demonstration, we have presented a guidebook that will explain the way to mount a drive in Ubuntu. Additionally, with the mounting procedure, we have provided the method to create the partitions of externally inserted storage devices.

About the author

Adnan Shabbir