Introduction / Why This Is Needed
Working with external storage is a basic skill for any Linux user. Unlike Windows or macOS, Linux often does not mount USB drives automatically, especially if they use an uncommon filesystem (like NTFS from Windows). This guide explains how to manually connect, use, and safely eject any USB flash drive or disk, as well as solve common problems you might encounter.
After completing these steps, you will be able to:
- Connect USB drives with any common filesystem (FAT32, exFAT, NTFS, ext4).
- Configure permissions for a regular user.
- Format drives for specific tasks.
- Safely remove devices without risking data loss.
Requirements / Preparation
Before you begin, ensure:
- You have administrator privileges (sudo) to execute mount and format commands.
- For working with NTFS filesystems, install the
ntfs-3gpackage:- Ubuntu/Debian:
sudo apt install ntfs-3g - Fedora:
sudo dnf install ntfs-3g - Arch:
sudo pacman -S ntfs-3g
- Ubuntu/Debian:
- For exFAT (the optimal choice for cross-platform compatibility), install
exfat-utilsandexfat-fuse:- Ubuntu/Debian:
sudo apt install exfat-fuse exfat-utils - Fedora:
sudo dnf install exfat-utils fuse-exfat - Arch:
sudo pacman -S exfat-utils
- Ubuntu/Debian:
- The USB drive is physically connected to the computer.
Step-by-Step Guide
Step 1: Identify the Device and Its Partition
First, you need to see how the system recognizes your drive. Plug in the flash drive and run in the terminal:
lsblk
You will see a table similar to this:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 238,5G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
└─sda2 8:2 0 238G 0 part /
sdb 8:16 1 14,9G 0 disk
└─sdb1 8:17 1 14,9G 0 part /media/user/FLASH
sr0 11:0 1 1024M 0 rom
Look for the device with a size matching your flash drive. Usually it's sdb, sdc, etc. (the main disk is sda). The partition is the entry with the same name but with a number (e.g., sdb1). Pay attention to MOUNTPOINT—if it's already present, the flash drive is already mounted.
💡 Tip: If
lsblkdidn't show your flash drive, trysudo fdisk -lfor a more detailed list of all disks. If the device isn't visible at all, check the cable or USB port.
Step 2: Create a Mount Point
A mount point is just a regular folder in your filesystem through which you will access the drive's files. Create it in /media (the standard location) or in your home directory (~/).
sudo mkdir -p /media/usb
Or, if you want to mount in your home directory without sudo:
mkdir -p ~/usb_drive
Step 3: Mount the Device
This is the key step. The mount command links the drive's partition to the mount point.
Basic option (FAT32/exFAT, auto-detection):
sudo mount /dev/sdb1 /media/usb
Option with specifying the filesystem (if auto-detection fails):
sudo mount -t ntfs /dev/sdb1 /media/usb
Replace ntfs with exfat, vfat (FAT32), or ext4 depending on your filesystem.
Setting permissions for a regular user (the most common issue!):
By default, mount makes files accessible only to root. To allow the current user (with ID 1000) to read and write, use the uid and gid options:
sudo mount /dev/sdb1 /media/usb -o uid=1000,gid=1000,umask=022
uid=1000,gid=1000— assigns ownership and group for all files on the flash drive.umask=022— sets permissions:755for directories and644for files (owner has full access, others have read-only).
How to find your UID/GID?
id -u # outputs uid (usually 1000)
id -g # outputs gid (usually 1000)
⚠️ Important: Replace
/dev/sdb1with your own partition found in Step 1! Mounting the wrong partition can lead to data loss.
Step 4: Work with Files
After a successful mount (with no errors), all files from the drive will be accessible in the /media/usb folder (or whichever you specified).
ls /media/usb
Now you can:
- Copy files:
cp /media/usb/file.txt ~/Documents/ - Edit:
nano /media/usb/notes.txt - Delete:
rm /media/usb/temp.tmp
Step 5: Safely Eject the Drive
Never unplug the flash drive while the indicator is blinking or while you are working with its files! This will guaranteed cause data corruption.
- Ensure all file manager windows open on the flash drive are closed.
- Run the unmount command:
Or, if you mounted withoutsudo umount /media/usbsudoand permission settings:umount /media/usb. - Wait until the access indicator on the flash drive itself (if it has one) turns off.
- Now you can physically disconnect the device.
Verification
- Successful mount: The
mountorlsblkcommand will show your mount point (/media/usb) in theMOUNTPOINTcolumn. - File access: You can
lsthe folder's contents and read/write files without "Permission denied" errors. - Safe ejection: After
umount, thelsblkcommand should no longer show aMOUNTPOINTfor your partition (/dev/sdb1).
Common Issues
Issue: "mount: /media/usb: special device /dev/sdb1 does not exist."
- Cause: You specified the wrong device (e.g.,
sdb1, but the flash drive issdc1). - Solution: Rerun
lsblkafter plugging in the flash drive and find the exact name. It often changes upon reconnection.
Issue: "mount: unknown filesystem type 'ntfs'"
- Cause: The NTFS driver (
ntfs-3g) is not installed. - Solution: Install the package as described in the Requirements section, or reformat the flash drive to
exFATorFAT32.
Issue: "Permission denied" when trying to write.
- Cause: The flash drive was mounted with root-only permissions.
- Solution: Unmount (
sudo umount /media/usb) and mount again with theuid=1000,gid=1000options (or your own IDs). Alternative: change permissions after mounting:sudo chmod -R 755 /media/usb(less secure).
Issue: The flash drive mounts itself, but to the wrong folder or with wrong permissions.
- Cause: Automounting via the graphical shell (UDISK2) sometimes doesn't work as needed.
- Solution: Disable automounting in your file manager settings and mount manually via the terminal as described above, with the desired parameters. For a permanent solution, you can configure a rule in
/etc/fstab.