In this post, we will describe how you can mount a USB drive in a Debian OS in case it is not detected by the system automatically.
We use the Debian 11 OS to describe the procedure mentioned in this article. This procedure is also applicable to the previous Debian releases.
Mounting a USB drive
Step 1: Plug in the USB drive to any of the available USB ports in your computer.
Step 2: Once you plugged in the USB drive, check the USB drive name and the file system type drive used. To do this, launch the terminal application in your Debian 11 OS and issue the following command:
You will receive an output that is similar to that in the following screenshot. Scroll down the output and you will see your USB drive possibly at the end of the output labeled as sda, sdb, sdc, sdd, etc. Note down the name of your USB drive and the file system as you may need it later. In our scenario, the USB drive name is “/dev/sdb1” and the file system is “FAT32”.
Step 3: The next step is to create a directory that serves as the mount point for the USB drive. To create the mount point directory, issue the following command in the terminal:
Let’s create a mount point directory named USB under the /media directory:
Step 4: Then, to mount the USB drive to the mount point that you created, issue the following command in the terminal:
In our scenario, we will mount the USB drive /dev/sdb1 to the mount point that we created as /media/USB/. The command is as follows:
Step 5: To verify if the USB drive is mounted on the mount point successfully, issue the following command:
In our scenario, the command would be:
The output in the following screenshot shows that our USB drive /dev/sdb1 has been mounted on the mount point /media/USB. In case the command does not show any output, it means that the device is not mounted.
Step 6: To explore the mounted USB drive, move inside the mounted directory using the cd command:
Now, you can navigate the directories in the USB drive in the same way as you do with the other directories in your file system. To list the files in the USB, use the ls command.
You can also access and explore the USB drive through the File manager of your system.
Auto-Mount the USB Drive in Debian 11
You can also auto-mount the USB drive when it is plugged into the system. To do this, edit the /etc/fstab file in a text editor using the following command:
Add the following entry at the end of the file, replacing the /dev/sdb1 and vfat with your USB device name and filesystem:
Then, save and exit the text editor.
Now, run the following command to mount all the devices:
This command mounts all the USB drives that are added to the /etc/fstab file but have not yet been mounted. Also, the next time you restart your system with a USB drive plugged in, your USB drive will be automatically mounted.
Unmounting a USB Drive
If you no longer want to use the mounted USB drive, you can unmount or detach it. However, before attempting to unmount it, make sure that there are no other operations in progress on the mounted USB drive. Otherwise, the drive won’t detach and you’ll get an error message.
To unmount the USB drive, type umount followed by the mount point directory or the device name as follows:
In our scenario, it would be:
If you see no output, it means that all went well and your USB drive is unmounted from the system. You can also confirm it from your File Manager’s left sidebar.
To delete the mount point directory, issue the following command:
In this article, you learned how to mount a USB drive in a Debian OS and how to unmount it when you need to remove the drive. I hope it will be helpful whenever you need to mount/unmount a USB drive in your system.