In this tutorial, we will learn the steps to mount USB Drives in Linux, using Step-by-Step instructions.
Steps to Mount USB Drives in Linux
Let’s go over the steps without any further delays. The entire process is extremely easy and I’ll walk you through it as a beginner.
Step 1: Plug In The USB Drive
Plug in the USB Drive in the correct USB Port (check for 2.x/3.x specific ports for better performance). Make sure your hardware is all fine and just with that we are done with Step 1 !
Step 2: Identify Your USB Drive
To use our USB Device, first, we need to identify it. Now there are a couple of different commands which can be used here. However, we will go with trusty old
fdisk which lists our USB Drive along with its model name, the drive’s capacity, and much more!
Once the USB drive has been plugged in, it will be registered as a new block device in
/dev/ directory ( Remember that everything in Linux is a file!). To list all block devices, we can type:
This should return something like follows :
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931.5G 0 disk ├─sda1 8:1 0 512M 0 part /boot/efi ├─sda2 8:2 0 929G 0 part /var/lib/lxd/storage-pools/default └─sda3 8:3 0 2G 0 part [SWAP] sdb 8:16 1 57.3G 0 disk └─sdb1 8:17 1 57.3G 0 part
Here sda is the primary block device whereas
sda1, sda2 and sda3 are the various partitions where the components of the running Operating System are located. Next comes sdb which represents our USB Drive as a block device. Likewise, sdb1 denotes the partition on the USB Drive in our case.
If you have multiple hard disks installed, it will be different for you. From the above output, we can also see the size of various partitions as well their mount points. As one can see, at present our USB Drive is not mounted but we’ll fix that in a minute 😀
Note that the name of our USB block device may be something other than sdb, but it’s almost always of the form sdX, where X usually is an smaller case alphabet like ‘b’, ‘c’, ‘d‘ and so on but is seldom ‘a’ as it usually denotes the primary block device containing the Operating System. Also
Moving on, we can identify our USB Drive using the following :
$ sudo fdisk -l
In the output, we should get an output like this :
Disk /dev/sdb: 57.3 GiB, 61530439680 bytes, 120176640 sectors Disk model: Ultra Fit Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x8cfe0668
From the given output we can clearly identify our USB Drive’s model, size and other information which can help us pinpoint our USB Drive. Note the Block Name from here, which is /dev/sdb in the given example, and proceed to the next step.
Step 3: Creating A Mount Point
Now that we have identified which Block Device we want to mount, we would need a place to mount it to. Usually, we make a folder under /mnt directory using the mkdir command:
$ sudo mkdir /mnt/USB
With this, we finally have a place to mount our block device. Onto the next step !
Step 4 : Mount The Block Device
Finally, we can now mount our USB Drive in the folder we made earlier! This can be easily done via the
mount command. Following our example, remember that we had our USB Drive registered as the block device /dev/sdb? Remember how it had a partition /dev/sdb1? We cannot mount block devices, rather we shall mount this partition as follows:
$ sudo mount /dev/sdb1 /mnt/USB/
And now, we can access the contents of our USB Drive right as if it were just another folder on our Desktop. We can also change the ownership of the folder where we mounted our USB Drive as such :
$ sudo chown $USER /mnt/USB/
After the above command, you no longer need to type
sudo repeatedly whenever we move data to-and-from our USB Device! Just to validate that our USB Drive has been mounted correctly, we can return to our good friend
lsblk and it should show us an output like:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931.5G 0 disk ├─sda1 8:1 0 512M 0 part ├─sda2 8:2 0 929G 0 part /home └─sda3 8:3 0 2G 0 part [SWAP] sdb 8:16 1 57.3G 0 disk └─sdb1 8:17 1 57.3G 0 part /mnt/USB
As we can see, our USB Drive is mounted at the folder we previously created ( /mnt/USB ) and hence we have successfully mounted our USB Drive !
Bonus: How To Unmount USB Drive?
Once we are done with all our desired USB operations, it is good practice to unmount our USB Drive before physically removing it from our machine. This can be achieved via the
umount command ! Just simply type in:
$ sudo umount [FOLDER WHERE DRIVE IS MOUNTED]
Staying consistent with our previous example, this would translate to:
$ sudo umount /mnt/USB
Just with that, we are done and we are free to remove our physical media like usual!
Here we had an overview of how to mount USB Drives in Linux machines. Note that sometimes, the mount command fails to mount our USB Drive and that’s primarily because of file types: The USB Drive might have a different file system than that of the Operating System. In such cases, the -t flag can be used to specify the type of file system you want to mount. For more information, check out the man pages for mount.