Linux Commands

How to Mount USB Drive on Linux

We live in the modern age of technology where there are multiple important variables to keep track of. But arguably, the biggest variable today is “data”. With some maturing and emerging technologies, everything is being centered around the quantity and quality of data. Thus, gathering and protecting data has become paramount.

These days, it’s quite common to see people carrying their data around at all times. Different devices and technologies are used for this purpose, including a certain device called USB (Universal Serial Bus).

A USB is an electronic communication protocol (ECP) most commonly used for computer accessories and other small-end electronic devices, either for data transfer or power transfer. Although USBs are being phased out slowly due to technologies such as “Cloud Computing”, there is a sense of privacy and security with using USBs that you don’t get with other methods.

Accessing USBs is straightforward. It is a plug-and-use device, so the stick only needs to be connected to your computer via a USB port. Usually, USBs mount themselves automatically to your system regardless of the operating system, but there are instances where there is a problem, and the USB refuses to connect.

For such times, if you are using a Linux distro, it is best to use the Terminal and execute your way to mount the USB in your computer. This article will be guiding you on how exactly you can achieve this task.

Although it is time-consuming, once you know how to mount a USB in Linux, you will feel lightened, and it will be easier for you to perform it the next time when needed. So follow these instructions to get a proper hang of it.

1) Plugin Your USB Drive into Your PC

First, you need to plug in your USB drive to your Linux-based personal computer (PC), in which you want to access the USB drive.

2) Detecting the USB Drive on Your PC

The second step is the most important and easy step to accomplish. After plugging in your USB to your computer, the system will add a new block device into the /dev/ directory. To check that, use the following command. But first, open your Command Terminal and then type the following command:

$ sudo fdisk -l

The resulting screen should be seen with an output like this:

The result above shows that device boot, blocks, id, and system format are displayed. After this step, you need to create a mount point.

3) Create a Mount Point

For creating a mount point, just type the following command:

$ mount /dev/sdb1 /mnt

In the command mentioned above, “sbd1” refers to the name of your USB Device.

4) Creating a Directory in the USB Drive

We move on to the next step. In this step, you must create a directory in the mounted device. For that, use the following command:

$ cd /mnt
/mnt$ mkdir John

The above commands will create a directory named “John” in the USB Drive. You can create the directory of your desired name by replacing it with John. For example.

$ cd /mnt
/mnt$ mkdir Google

This command will create a directory in the USB Drive with the name “Google”. After completing this step, you have now successfully mounted the USB drive in your Linux system.

5) Delete a Directory in USB Drive

After learning about creating a Directory on your USB, it’s time to learn about how you can delete a directory on your USB Drive. To delete a directory, write the following command.

/mnt$ rmdir John

The above-mentioned command will delete the drive named as “John”. But if you want to delete a directory with your desired name, just replace it with “John”. For example.

/mnt$ rmdir Google

The above code deletes the directory named “Google”. Similarly, you can write any of your desired names to delete a directory on your USB Drive on a Linux-operated computer.

6) Formatting the Mounted USB in Linux

In order to format a USB Flash Drive, you need to unmount the drive first. Use the following command to unmount the USB.

$ sudo umount /dev/sdb1

In the aforementioned command, “sbd1” refers to the name of your USB Device. Next, you have to choose either of the following codes as per your USB Drive file systems:

For VFAT (FAT32) File System
To format VFAT (FAT32) file system, use:

$ sudo mkfs.vfat /dev/sdb1

In the command mentioned above, “sbd1” refers to the name of your USB Device.

For NTFS File System
To format NTFS file system USB Drive, use:

$ sudo mkfs.ntfs /dev/sdb1

For EXT4 File System
For formatting EXT4 file system USB Drive, use:

$ sudo mkfs.ext4 /dev/sdb1

Conclusion

This guide covered how to mount a USB drive in your Linux system. It also described the commands you can use to delete directories or format your USB device. We hope that we can help you out and that you can use your USB with your Linux without any problems.

About the author

Zeeman Memon

Hi there! I'm a Software Engineer by degree, Blogger by skills who loves to write about tech, develop websites & do SEO. You can reach out to me on LinkedIn.