Easy Guide to Mount USB Drive in Linux

How to Mount USB Drive in Linux?

In today’s data-driven world, USB drives remain a popular way to carry information.

While modern Linux systems with graphical interfaces often mount USB drives automatically, you might encounter situations where manual mounting through the terminal is necessary.

There are different methods you can test to mount USB drive in Linux Ubuntu, Debian, and CentOS:

  • Plugin your USB Drive.
  • Detecting USB hard drive on Your system.
  • Create a Mount Point.
  • Mount USB Drive.
  • Access USB drive data.
  • Unmount USB Drive.
  • Mount your USB Drive Permanently.

The mount command is used in Unix-based systems like Linux and macOS to make a file system accessible.

You can also use the mount command manually to:

  • Mount external drives like USB drives or SD cards.
  • Access file systems on network locations.
  • Mount special file systems like optical discs.

Prerequisites to Mount USB Drive in Linux

Provide the options below to let this tutorial work correctly and move on.

  • A Server running Linux VPS.
  • A non-root user with sudo privileges.
  • Access to the Linux Terminal.

Solutions to Mount USB in Linux [Using Command-line]

This guide will equip you with the steps to mount any USB drive on Linux distributions such as Debian, Ubuntu, and CentOS through a user-friendly graphical interface or the command line.

You can also mount remote file systems over SSH. This allows you to access files and folders on another computer on your network.

You’ll easily access and manage the files on your USB drive by the end.

1. Plugin your USB Drive

The first step to accessing your USB drive on Linux is physically connecting it to your computer.

Find an available USB port on your Linux machine and securely plug the USB drive in.

Once connected, your computer will recognize the drive, and you can proceed with the following steps to mount it and access its contents.

2. Detecting USB hard drive on Your system

When you plug in a USB drive to your Linux computer, it gets recognized by the system and assigned a name, typically something like /dev/sdb. This name helps the system locate the USB drive.

To find this name, run the command below in the terminal:

sudo fdisk -l

This command might list devices besides your USB drive, so look for entries like /dev/sdb or /dev/sdc that doesn’t seem to be your internal hard drive.

Once you’ve identified the correct device name, you can mount the USB drive and access its contents.

3. Create a Mount Point

Before accessing the files on your USB drive, you must create a special directory on your computer that acts as a doorway.

This directory called a mount point, is like an empty office waiting to be filled with furniture (your USB drive’s files).

Creating this mount point is simple. You can use the mkdir command followed by the desired location for the mount point.

The command below would create a mount point named “usb-drive” within the existing “/media” directory on your computer:

sudo mkdir /media/usb-drive

This gives you a designated spot to access your USB drive’s contents once it’s mounted.

4. Mount USB Drive with mount Command

Now that you’ve identified your USB drive’s name and created a mount point, it’s time to connect them!

The mount command bridges the gap between your computer’s system and the USB drive.

To do this, use the mount command followed by the USB drive’s device name (like /dev/sdb) and the mount point you created (like /media/usb-drive).

To mount your USB drive, run the command below, making its contents accessible through the /media/usb-drive directory on your computer.

sudo mount /dev/sdb /media/usb-drive

Once mounted, you can use your file manager or terminal commands to browse and interact with the files on your USB drive.

You can easily verify if the mount was successful using the mount command with the grep command to filter the output for your USB drive’s device name.

If you see a line mentioning your device name, then your USB drive is mounted and ready to use!

5. Access USB drive data

Once you’ve successfully mounted your USB drive, accessing its data is a breeze.

Just navigate to the mount point you created, like “/media/usb-drive” using the cd command:

# cd /media/usb-drive

This tells your computer to look for files and folders within that directory.

Once there, you can use familiar commands like ls to list the contents of the USB drive, just as you would with any other folder on your computer.

Now you’re free to manage the files on your USB drive like a pro.

You can create new folders, delete unwanted files, copy data between your computer and the USB drive, and more!

6. Unmount USB Drive

Safely removing your USB drive on Linux involves two main steps:

Closing any open files and then unmounting the drive itself.

First, make sure you’ve closed any programs or files that might be using the USB drive. Trying to unmount a drive that’s in use will result in an error message.

Once everything is closed, open the terminal and use the umount command followed by the mount point (like /media/usb-drive).

To unmount USB drive, run:

sudo umount /media/usb-drive

If you’re unsure of the exact mount point location, you can use the df command in the terminal to see a list of mounted devices.

Once unmounted, it’s safe to physically remove the USB drive from your computer.

7. Mount your USB Drive Permanently

Permanently mounting your USB drive on Linux saves you time and hassle. Instead of manually mounting it every time, you can configure it to mount automatically at boot.

Here’s how:

Find your USB drive’s UUID running:

lsblk /dev/disk/by-uuid/

Edit /etc/fstab with sudo nano /etc/fstab.

Run the command below to add a new line with the format

/dev/disk/by-uuid/your_UUID /mount/point filesystem options 0 0

Replace the placeholders with your info:

your_UUID : your USB drive’s UUID from step 1

/mount/point : where you want to access the drive (e.g. /media/usb-drive)

filesystem : the file system type (e.g. vfat for FAT32, ntfs for NTFS)

Save (Ctrl+O) and exit (Ctrl+X) the editor.

(Optional) Run mount -a to mount the drive now.

Now, your USB drive will be mounted automatically whenever you plug it in!

Is it safe to permanently mount my USB drive?

Yes, permanent mounting is safe as long as you follow the instructions carefully.

Editing /etc/fstab requires a bit of caution, but as long as you enter the correct information for your USB drive, it’s a convenient way to avoid manual mounting each time.

How do I safely remove my USB drive after mounting it permanently?

Even with permanent mounting, it’s good practice to unmount the drive before physically removing it.

Use the umount /mount/point command (replace /mount/point with your mount point) in the terminal.

This ensures all data is written properly before disconnecting the drive

My USB drive isn’t showing up after I plug it in. What should I do?

First, try a different USB port on your computer. If that doesn’t work, the issue might be with the drive itself. You can check for the drive using the fdisk -l command in the terminal.

Why is my USB drive still not mounting automatically after following the steps to mount permanently?

Double-check that your UUID is correct in the /etc/fstab file. A typo here can prevent mounting.

Also, try running sudo mount -a in the terminal to manually trigger a mount for all devices listed in /etc/fstab.

I see multiple entries for /dev/sdX in the fdisk -l output. How do I identify my USB drive?

Look for the drive size and compare it to the size of your USB drive. Internal hard drives are typically much larger.

You can also unplug your USB drive and see which entry disappears from the fdisk -l output.

I get an error message “umount: target is busy” when trying to unmount the drive. What now?

Umount Target is Busy” Error in Linux means a program is still using the USB drive.

Close any file explorer windows or programs that might be accessing the drive, then try unmounting again.

My USB drive seems mounted, but I can’t see any files. What’s wrong?

The drive might require a file system check. Try running sudo fsck /dev/sdX (replace sdX with your drive name) in the terminal.

Important: Only use fsck command if you’re comfortable with terminal commands, as improper usage can damage your data.

Conclusion

While manually mounting your USB drive on Linux works, this guide offers a more convenient solution: permanent mounting.

By editing the /etc/fstab file and including your USB drive’s UUID, you can ensure the drive automatically mounts upon plugging in, saving you time and frustration in the long run.

Remember to be cautious when editing this file, and always double-check your information before saving.

The mount command offers various options for customization, but the basic functionality is to integrate different file systems into the overall file hierarchy for easy access.

Leave a Reply

Your email address will not be published. Required fields are marked.