Mounting a USB drive is easy these days on most Linux distros. But you may encounter some weird quirky distros that demand your terminal knowledge for mounting a USB drive successfully without it doing the work for you.
For instance, if you’ve tried installing a Linux server or Slackware for general purpose use or tried Linux From Scratch (LFS), they mostly come in terminal mode before you get on with the GUI stuff. This article will guide you on how to mount a USB drive in case you ever encounter this situation in a terminal session.
Default mount operation on most Linux distro
Before we jump into mounting a USB drive using a terminal session, I want to point out that if you’re following this article on Ubuntu Linux or those popular Linux distros (Fedora, Debian, Mint, Zorin, etc) with GUI already set up for you after you installed the OS, that the procedure will slightly vary. First, you have to unmount the drive using a terminal program and then mount it back again. That’s because these distros automount the drive for you the moment you insert it.So if you are using a popular general-purpose Linux distro, execute the below command to unmount your drive first after you insert it:
sudo umount /dev/sdb
Then proceed on below to follow the procedure for mounting the USB drive.
How to mount using terminal
USB drives are usually labeled as sdb, sdc, sdd, etc but they may vary from hardware to hardware. You can check out all the devices block currently connected on your computer using the command lsblkBelow is the output displayed on my terminal program when I executed the above command on my Debian system:
Those sda(s) are all the partitions on my hard drive, sr0 is the ejectable disc drive, and we see sdb which is the USB drive we are interested in mounting. What you see over the above screenshot will be similar to yours too. To mount a USB drive we will use the command mount:
source destinationWhere <source> is your device block and <destination> is your mount directory.
sudo mount /dev/sdb /mnt
After you mount the USB drive on your computer, execute lsblk command one more time to make sure your drive is mounted on the /mnt directory.
Moreover, you can also browse to the /mnt directory using either cd command or a file manager program. To unmount the drive, use the below command:
sudo umount /dev/sdb
This does not make your drive safe to be ejected. You have to eject the drive using the eject command as:
sudo eject /dev/sdb
In summary, we’ve learned how to mount a USB drive on our computer and even safely eject it. Remember, the drive names may be labeled as sdb, sdc, or sdd, and so on depending on your hardware. If you know the drive size, you can easily figure out the label name without much effort 🙂 Hope you enjoyed following this tutorial and please don’t hesitate to leave a comment below in case you have doubts or mistakes worth pointing out.