USB

How to Mount a USB Drive in Debian

Most Linux distributions are configured to automatically mount USB devices as soon as they are inserted into the USB ports. The system itself mounts the USB drives to a directory under /media folder and you can access them using your File Manager. However, in some cases, you are still required to mount the USB drives manually in order to access them.

In this article, we will discuss how to mount a USB drive in a Debian OS in case it is not detected by the system automatically.

We have used Debian 10 OS for describing the procedure mentioned in this article.

Mounting a USB drive

Step 1: Plug-in the USB drive to any of the available USB ports in your system.

Step 2: After plugging the drive, you will need to find out the USB device name and the file system type it is using. For that, open the Terminal application in your Debian OS and execute the following command as sudo:

$ sudo fdisk –l

When you execute the above command, you will get the output similar to below. you will find the USB device probably at the end of the output labeled as sdb, sdc or sdd, etc.. Note down the device name and the file system. In our case, it is sdb1 running a FAT32 file system.

Step 3: Now we will have to create a mount point directory where we want to mount our USB drive. To do so, use the following syntax in Terminal:

$ sudo mkdir /media/<mountpoint_name>

For instance,

$ sudo mkdir /media/USB

Step 4: Next, in this step, we will mount the USB drive to the mount point we created above. The syntax of command would be:

$ sudo mount <device_name> <mountpoint_directory>

For instance, to mount our USB drive /dev/sdb1 to the mount point /media/USB/, we have used the following command:

$ sudo mount /dev/sdb1 /media/USB/

Step 5: Use the following command to verify if the USB drive is mounted successfully.

$ mount | grep device_name

For instance, in our case:

$ mount | grep sdb1

The above output shows our USB drive has been mounted. In case you receive no output, then it implies the device has not mounted.

Step 6: To access and browse the mounted device, use the cd command as follows:

$ cd /media/USB/

Also, you can access and browse the USB drive through the Debian File manager program.

Unmounting a USB drive

Once you are done with using the mounted USB drive, you will need to unmount or detach it. But before going to unmount, make sure no other process is running on the drive, otherwise the drive will fail to detach and you will receive the error message.

To unmount the USB drive, type umount followed by the mount point directory or the device name as follows:

$ sudo umount <mountpoint_directory>

Or

$ sudo umount <device_name>

For instance, in our case it would be:

$ sudo umount /media/USB

Now the USB drive will be detached from the system and you will no longer see the mounted drive in your File manager.

After that, you can remove the mount point directory too by using the following command:

$ sudo rmdir <mountpoint_directory>

That is all there is to it! In this article, we have learned how to mount a USB drive in our Debian OS and also learned to safely unmount it. I hope it will be helpful whenever you need to mount/unmount the USB drive in your system.

About the author

Karim Buzdar

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.