USB (Universal Serial Bus) is a device which is used as a medium of communication between two peripherals, laptops and personal computers. We can save data on USB from one computer and can copy it to another computer by just using a plugin. When USB is plugged into a computer it is mounted by the operating system installed on that machine. By default the USB is automatically mounted by the operating system installed in a machine but sometimes because of some issue like USB storage device configurations are missing the USB devices are not automatically mounted when they are plugged in. In this case, we have to configure the USB storage devices so that they can be automatically mounted when the system is plugged in. Two methods to auto mount the USB drive on Ubuntu are going to be discussed in this post.

How we can auto mount USB drive on Ubuntu

As we discussed above, we can configure the USB drive so that it can be auto-mounted when plugged in if by default it is not automounted by two different methods. We will discuss both methods in detail in this post.

How UUID is used to auto mount the USB Drive

UUID (universal unique identifier) is used in Linux for the detection of the USB which is plugged in or for the identification of the partition used by the USB drive. Because of this we have to become a root user. We can be a root user by the following command, it will ask for a password so enter the password:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-147.png" data-lazy- height="169" src="data:image/svg xml,” width=”1283″>

The command sign has changed from “$” to “#” which means now we are in the root user mode.

In order to find out the details of the USB devices attached to our system we will use the following command:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-148.png" data-lazy- height="475" src="data:image/svg xml,” width=”1285″>

Now open the /etc/fstab file with the help of nano as:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-149.png" data-lazy- height="162" src="data:image/svg xml,” width=”1287″>

Now add the following text to the editor. You can save this by using your own address, we are using here /mnt/usb, also enter your unique UUID which you can copy from the above command that is of “blkid”.

UUID=9033-F09B /mnt/usb ext4 defaults 0 0

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-150.png" data-lazy- height="651" src="data:image/svg xml,” width=”1290″>

Now exit the editor by saving the file pressing CTRL X then type “y” and press ENTER. Now finally run the following command by using the following command.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-151.png" data-lazy- height="166" src="data:image/svg xml,” width=”1283″>

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-152.png" data-lazy- height="148" src="data:image/svg xml,” width=”1287″>

We can see it is showing that the device is already mounted because by default it is being mounted. If it isn’t mounted by default then it will be mounted by this command.

What is an alternate method to auto mount the USB Drive

We can mount USB in another way too. Open the terminal and use the “update” command to update the repository.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-153.png" data-lazy- height="232" src="data:image/svg xml,” width=”1287″>

Now we will also upgrade it so all the packages are upgraded as well.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-154.png" data-lazy- height="213" src="data:image/svg xml,” width=”1284″>

Now we will create the directory by using the command “mkdir” so that the usb drive can be mounted there:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-156.png" data-lazy- height="161" src="data:image/svg xml,” width=”1286″>

To find out the base name of the mounted USB drive we use the following command as we find out the name of our usb is /dev/sdb1:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-157.png" data-lazy- height="133" src="data:image/svg xml,” width=”1255″>

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-158.png" data-lazy- height="205" src="data:image/svg xml,” width=”1283″>

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-161.png" data-lazy- height="272" src="data:image/svg xml,” width=”1204″>

Now if we have the format of usb drive FAT32 or FAT16 system we will use the following command:

$ sudo mount -t vfat /dev/sdb1 /media/usb -o uid=1000,gid=100,utf8,dmask=027,fmask=137

And for the format of NTFS we will use the following:

$ sudo mount -t ntfs-3g /dev/sdb1 /media/usb

As our USB drive is of the FAT32 system, we will use the mentioned command for it:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-162.png" data-lazy- height="116" src="data:image/svg xml,” width=”1287″>

The usb drive is mounted successfully and we can access it and open its files. We go to the file and can check on the left side of the window the USB drive is present.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-164.png" data-lazy- height="650" src="data:image/svg xml,” width=”1295″>

How to unmount the USB drive

We can unmount the USB drive by using the umount command as:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/word-image-166.png" data-lazy- height="125" src="data:image/svg xml,” width=”1292″>

The USB drive will be unmounted successfully.

Conclusion

A lot of alternate methods are there to complete any task, so if we are getting issues in mounting the USB drive on the laptop, there is no need to panic, we can still manually mount the USB drive. In this post the two methods are discussed through which we can mount the USB drive; one is using the UUID command whereas the other one is more convenient by just making the directory where the USB Drive is being mounted and by running the command according to the format of your USB drive. Using the umount command we also showed how to unmount the USB drive. This post will make you understand how to mount the USB drive on Ubuntu.

About the author

<img data-del="avatar" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/hammad–150×150.jpg" height="112" src="data:image/svg xml,” width=”112″>

Hammad Zahid

I’m an Engineering graduate and my passion for IT has brought me to Linux. Now here I’m learning and sharing my knowledge with the world.