How to Mount USB Drive in Linux (Command Line Guide for Ubuntu, Debian, RHEL)

How to Mount USB Drive in Linux (Command Line Guide for Ubuntu, Debian, RHEL)

Mounting a USB drive in Linux allows you to access files stored on external storage devices such as flash drives, pendrives, or external disks. While modern desktop environments often mount USB devices automatically, many Linux administrators and power users prefer using command-line tools for better control and troubleshooting.

In this guide, you will learn how to identify USB devices, mount them manually using the mount command, verify the mounted filesystem, and safely unmount the device. The quick reference below summarizes the essential steps required to mount a USB drive in Linux.


Quick Steps: Mount USB Drive in Linux

To mount a USB drive in Linux using the command line:

StepCommand / Action
Identify USB devicelsblk
Check filesystem typeblkid /dev/sdb1
Create mount directorysudo mkdir /media/usb
Mount USB drivesudo mount /dev/sdb1 /media/usb
Verify mountmount | grep usb
Check mounted devicelsblk
Access USB filescd /media/usb
Safely unmount USBsudo umount /dev/sdb1
Remove temporary mount directorysudo rm -rf /media/usb

Step 1: Identify the USB Device in Linux

Before mounting a USB drive, you must first identify the correct device name assigned by the Linux kernel. When a USB storage device is connected, Linux creates a block device under /dev/ such as /dev/sdb or /dev/sdc. The actual partition is usually something like /dev/sdb1.

Identifying the correct device ensures you mount the right storage without affecting other disks on the system.

List USB drives using lsblk

The lsblk command is the easiest way to list all storage devices connected to the system. It displays disks, partitions, and mount points in a tree-like format.

text
lsblk

Example output:

text
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 931.5G  0 disk /
sdb      8:16   1  57.8G  0 disk
└─sdb1   8:17   1  57.8G  0 part

Here:

  • sdb represents the USB disk
  • sdb1 is the partition we will mount

The RM column indicates whether the device is removable.

Identify USB partitions using fdisk -l

The fdisk command provides detailed information about disks and partitions connected to the system.

text
sudo fdisk -l

Example output:

text
Disk /dev/sdb: 57.76 GiB
Device     Boot Start       End   Sectors  Size Id Type
/dev/sdb1       2048 121135103 121133056 57.8G  7 HPFS/NTFS/exFAT

This command helps confirm:

  • disk size
  • partition layout
  • partition type

This is useful when troubleshooting mount issues.

Check filesystem type using blkid

Before mounting a device, it is helpful to determine the filesystem type. The blkid command displays filesystem metadata including UUID and filesystem type.

text
sudo blkid /dev/sdb1

Example output:

text
/dev/sdb1: LABEL="USB_DISK" UUID="5E92CAC292CA9E41" TYPE="vfat"

Common filesystem types include:

  • ntfs
  • vfat (FAT32)
  • exfat
  • ext4

Knowing the filesystem helps determine which mount options or drivers are required.

Detect newly inserted USB devices using dmesg

The dmesg command displays kernel messages, including logs generated when hardware devices are connected.

Immediately after inserting the USB drive, run:

text
dmesg | grep -i usb

Example output:

text
usb 2-1: new high-speed USB device number 4 using xhci_hcd
sd 6:0:0:0: [sdb] Attached SCSI removable disk

This confirms the kernel has detected the USB device and shows the assigned device name.


Step 2: Create a Mount Point

Linux requires a directory where the filesystem of the USB drive will be attached. This directory is known as the mount point.

A mount point can be created anywhere, but common locations include:

  • /media
  • /mnt
  • /run/media

Create a mount directory using:

text
sudo mkdir /media/usb

After creating the directory, you can mount the USB device there.

You can also mount the device temporarily using /mnt if you do not want to create a permanent mount directory.

For example:

text
sudo mount /dev/sdb1 /mnt

Using /media/usb is recommended for removable devices because it keeps the filesystem organized.


Step 3: Mount the USB Drive in Linux

Now that you have identified the device and created a directory, you can perform the mount operation. Mounting connects the physical device partition to your directory structure.

In most cases Linux automatically detects the filesystem type when mounting a USB drive. However, if automatic detection fails or the required filesystem driver is missing, you may need to specify the filesystem manually.

text
sudo mount -t <filesystem> <device> <mount_point>

Example for an NTFS device:

text
sudo mount -t ntfs /dev/sdb1 /media/usb

Before mounting, make sure the required filesystem packages are installed on your system.


Mount NTFS USB drive

NTFS is commonly used on Windows systems. Linux requires the ntfs-3g driver to read and write NTFS partitions.

Mount command:

text
sudo mount -t ntfs /dev/sdb1 /media/usb

Required packages:

Debian / Ubuntu:

text
sudo apt install ntfs-3g

RHEL / Rocky / AlmaLinux:

text
sudo dnf install ntfs-3g

Mount FAT32 USB drive

FAT32 filesystems are supported natively in Linux through the vfat kernel driver, so most systems can mount FAT32 USB drives without installing additional packages.

Mount command:

text
sudo mount -t vfat /dev/sdb1 /media/usb

If utilities are missing, install:

Debian / Ubuntu:

text
sudo apt install dosfstools

RHEL / Rocky / AlmaLinux:

text
sudo dnf install dosfstools

Mount exFAT USB drive

exFAT is commonly used on modern flash drives and SD cards. Older Linux systems may require additional packages.

Mount command:

text
sudo mount -t exfat /dev/sdb1 /media/usb

Required packages:

Debian / Ubuntu:

text
sudo apt install exfat-fuse exfat-utils

RHEL / Rocky / AlmaLinux:

text
sudo dnf install exfatprogs

Step 4: Verify USB Drive Mount

Confirm mounted device using lsblk

The lsblk command shows the mount point associated with the device.

text
lsblk

Example output:

text
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 931.5G  0 disk /
sdb      8:16   1  57.8G  0 disk
└─sdb1   8:17   1  57.8G  0 part /media/usb

This indicates that the USB drive is mounted successfully.

Verify mount using mount command

You can also check mounted filesystems using the mount command.

text
mount | grep usb

Example output:

text
/dev/sdb1 on /media/usb type vfat (rw,relatime)

Access files from the mounted USB directory

Once the device is mounted, you can access the contents by navigating to the mount directory.

text
cd /media/usb

You can now list or manipulate files stored on the USB drive.

text
ls

Step 5: Unmount USB Drive in Linux

Once you finish working with the USB drive, it is important to unmount it properly before removing the device. Unmounting ensures that all buffered data is written to the disk and prevents filesystem corruption.

Linux provides the umount command to safely detach a mounted filesystem from the directory tree.

Unmount using device name

You can unmount the USB drive by specifying the device partition that was mounted earlier.

text
sudo umount /dev/sdb1

After running the command, the filesystem is detached from the system and the USB device can be safely removed.

Unmount using mount point

Alternatively, you can unmount the device using the mount directory instead of the device name.

text
sudo umount /media/usb

Both methods achieve the same result and can be used interchangeably depending on which identifier you prefer.

Fix "device busy" error during unmount

Sometimes you may encounter the following error when attempting to unmount the device:

text
umount: /media/usb: target is busy

This means that some process or terminal session is still accessing the mounted directory. To resolve this issue:

  • Exit any terminal currently inside the mount directory
  • Close applications accessing files on the USB drive

You can also identify processes using the device with:

text
lsof +f -- /media/usb

After stopping the processes, retry the unmount command.

In certain cases, a lazy unmount can be used:

text
sudo umount -l /media/usb

Step 6: Troubleshooting USB Mount Issues

Even when the correct commands are used, USB drives may sometimes fail to mount due to missing drivers, incorrect device identification, or permission issues. The following sections describe common problems and how to resolve them.

USB drive not detected

If the USB drive does not appear after connecting it, verify whether the Linux kernel has detected the device.

First list all block devices:

text
lsblk

If the USB drive is not visible, check kernel messages generated when the device was inserted:

text
dmesg | tail

You should see entries indicating that a new USB storage device has been detected. If nothing appears, try inserting the drive into another USB port or reconnecting the device.

Filesystem driver missing

Sometimes the mount operation fails because the system does not have the required filesystem driver installed.

For example, mounting an NTFS device without the proper driver may result in errors. Install the necessary packages and try mounting again.

Debian or Ubuntu systems:

text
sudo apt install ntfs-3g exfat-fuse exfat-utils

RHEL, Rocky Linux, or AlmaLinux systems:

text
sudo dnf install ntfs-3g exfatprogs

After installing the packages, reconnect the USB device and retry the mount operation.

Permission denied while mounting

If you receive a permission error while mounting the device, ensure the command is executed with administrative privileges.

text
sudo mount /dev/sdb1 /media/usb

Also verify that the mount directory exists and is accessible.

text
ls -ld /media/usb

If necessary, recreate the mount point and mount the device again.

Device busy during unmount

When attempting to unmount a device, you may see the following error:

text
umount: target is busy

This indicates that a process is still using the mounted directory.

Check which processes are accessing the mount location:

text
lsof +f -- /media/usb

Close the applications using the device or exit the directory in your terminal. Once no process is using the filesystem, run the unmount command again.

text
sudo umount /media/usb

Step 7: Permanently Mount USB Drive using /etc/fstab

The mounting steps described earlier attach the USB drive only temporarily. After a system reboot, the device will not be mounted automatically.

To make the mount persistent across reboots, you can create an entry in the /etc/fstab file.

Identify device UUID

Using the device name such as /dev/sdb1 is not recommended for permanent mounts because device names may change when additional disks are connected.

Instead, use the UUID (Universally Unique Identifier) of the partition.

text
sudo blkid /dev/sdb1

Example output:

text
/dev/sdb1: LABEL="USB_DISK" UUID="2c566ef5-fe73-4e1c-aa71-9a8cd77c0b31" TYPE="ntfs"

Copy the UUID value for use in the fstab entry.

Add mount entry to /etc/fstab

Open the /etc/fstab configuration file.

text
sudo nano /etc/fstab

Add a new entry at the end of the file:

text
UUID=2c566ef5-fe73-4e1c-aa71-9a8cd77c0b31 /media/usb ntfs defaults,nofail,user 0 0

The fields represent:

  • device identifier (UUID)
  • mount point
  • filesystem type
  • mount options
  • dump option
  • filesystem check order

The mount options:

  • nofail: Prevents the system from hanging at boot if the USB isn't plugged in.
  • user: Allows non-root users to mount/unmount the device.

After saving the file, the system will attempt to mount the device automatically during boot.

Test configuration safely

Before rebooting the system, test the configuration to ensure the fstab entry is correct.

text
sudo mount -a

If no errors are reported, the configuration is valid and the device will mount automatically when the system starts.


Step 7: Format or Change Filesystem of USB Drive in Linux

Formatting prepares a USB storage device with a new filesystem. This operation removes the existing filesystem structure and creates a new one, allowing the device to be used with a different format.

Changing the filesystem type of a USB drive usually requires formatting the device. Before proceeding, ensure that the USB drive does not contain any important data because formatting permanently deletes all files.

Linux provides the mkfs utilities to create filesystems on storage devices.

Format USB drive as FAT32

To format the USB drive with the FAT32 filesystem:

text
sudo mkfs.vfat /dev/sdb1

FAT32 is widely supported across Linux, Windows, and macOS systems, making it a good choice for maximum compatibility.

Format USB drive as NTFS

To format the USB drive using the NTFS filesystem:

text
sudo mkfs.ntfs /dev/sdb1

NTFS supports large files and is commonly used on Windows systems.

Format USB drive as exFAT

To format the USB drive with the exFAT filesystem:

text
sudo mkfs.exfat /dev/sdb1

exFAT is often used on modern flash drives and SD cards because it supports large files without the 4 GB limit present in FAT32.

Format USB drive as EXT4

If the USB drive will be used primarily on Linux systems, you can format it with the EXT4 filesystem.

text
sudo mkfs.ext4 /dev/sdb1

EXT4 provides journaling, better performance, and improved reliability for Linux environments.

Common mkfs tools used for filesystem creation

Linux provides several mkfs utilities for creating filesystems on storage devices.

text
mkfs.vfat
mkfs.ntfs
mkfs.exfat
mkfs.ext4

Each command initializes the device with a different filesystem type, allowing you to choose the format best suited for your usage requirements.


Mount USB Stick, Flash Drive, or Pendrive in Linux

USB storage devices are often referred to by different names such as USB stick, flash drive, thumb drive, or pendrive. In Linux, all of these devices are handled the same way because they are recognized as removable block storage devices.

Understanding removable USB device naming

When a USB drive is connected, the Linux kernel assigns it a device name under the /dev directory. The first internal disk usually appears as /dev/sda, while removable drives may appear as /dev/sdb, /dev/sdc, and so on.

Each partition inside the device is identified with a number:

text
/dev/sdb1
/dev/sdb2

The partition containing the filesystem is the one that must be mounted.

You can confirm the device name using:

text
lsblk

Mounting different removable USB storage devices

Regardless of whether the device is called a flash drive, pendrive, or USB stick, the mounting procedure remains the same.

text
sudo mount /dev/sdb1 /media/usb

Once mounted, the files stored on the device become accessible through the mount directory.

text
cd /media/usb

Frequently Asked Questions

1. How do I mount a USB drive in Linux using command line?

First identify the USB device using lsblk or fdisk -l. Then create a mount point such as /media/usb and mount the device using sudo mount /dev/sdb1 /media/usb.

2. How do I find the USB device name in Linux?

You can identify the USB device using commands such as lsblk, blkid, fdisk -l, or dmesg. These commands list connected storage devices and their partitions.

3. How do I unmount a USB drive in Linux?

Use the umount command followed by the device name or mount point, for example sudo umount /dev/sdb1 or sudo umount /media/usb.

4. How do I permanently mount a USB drive in Linux?

You can permanently mount a USB drive by adding its UUID entry to the /etc/fstab file and specifying the mount point and filesystem type.

5. Why is my USB drive not mounting in Linux?

This can happen if the filesystem driver is missing, the device name is incorrect, or the USB drive is already mounted. Installing packages like ntfs-3g or dosfstools and verifying the device using lsblk can help resolve the issue.

Summary

Mounting a USB drive in Linux involves identifying the correct device, creating a mount point, attaching the filesystem, and verifying that the device has been mounted successfully.

Key commands used to mount USB drives in Linux

The following commands are commonly used while working with USB storage devices:

text
lsblk
blkid
mount
umount
mkfs

These tools allow you to identify storage devices, mount filesystems, and manage removable media safely.


Best practices when working with removable storage

When working with USB drives in Linux, follow these best practices to avoid filesystem corruption and data loss:

  • Always verify the correct device name before mounting.
  • Use a dedicated mount directory such as /media/usb or /mnt/usb.
  • Unmount the device before physically removing it.
  • Use UUID entries when configuring permanent mounts.
  • Ensure required filesystem drivers are installed.

By following these steps and best practices, you can reliably mount, access, and manage USB storage devices across different Linux distributions.

Omer Cakmak

Omer Cakmak

Linux Administrator

Highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware.