Inserting a USB flash drive or external hard drive into an Ubuntu desktop or server only to see the error dialogue: “Error mounting /dev/sdX at /media/user/USB: Command-line `mount -t …` exited with non-zero exit status” or “Failed to mount: permission denied” is a frustrating roadblock when transferring files.
This failure occurs when Windows Fast Startup leaves an NTFS volume locked in a “dirty” hibernation state, when missing file system packages (like exFAT or NTFS-3G) prevent the kernel from parsing partition tables, or when Udisks2 daemon permission policies block automatic mounting. Follow these step-by-step terminal instructions to repair and mount your USB drive cleanly.
Repair NTFS Dirty Bit and Unclean Volume Locks
If the USB drive was previously connected to a Windows computer that used “Fast Startup” or was unplugged without using “Safely Remove Hardware,” Windows leaves a dirty volume flag that causes the Linux NTFS driver to reject mounting to prevent corruption.
- Open the Terminal application (Ctrl + Alt + T).
- Identify your USB drive’s device partition identifier:
lsblk -f - Locate your USB drive in the list (e.g.
/dev/sdb1or/dev/sdc1). Note the device path carefully. - Run the open-source NTFS repair utility to clear the dirty flag and volume hibernation lock:
sudo ntfsfix /dev/sdb1(Replace
/dev/sdb1with your exact device partition). - Unplug the USB drive, wait five seconds, and plug it back in. In most instances, Ubuntu will now automatically mount the drive and display it in the file manager.
Install Essential exFAT and NTFS Filesystem Packages
Modern high-capacity USB flash drives (64 GB and above) are pre-formatted as exFAT. If your Ubuntu installation lacks the required userspace drivers, mounting fails.
- Update your local package lists:
sudo apt update - Install the exFAT and NTFS utilities:
sudo apt install -y exfat-fuse exfatprogs ntfs-3g - Once installed, unplug and re-insert your USB drive to allow the kernel to initialize the appropriate filesystem handler.
Mount the USB Drive Manually to a Custom Directory
If the graphical file manager (GNOME Files/Nautilus) continues to fail due to desktop permission policies, you can mount the drive directly through the terminal.
- Create a target mount directory with proper administrative permissions:
sudo mkdir -p /mnt/usbdrive - Mount the partition manually with standard user read/write access:
sudo mount -o uid=1000,gid=1000 /dev/sdb1 /mnt/usbdrive - Navigate to
/mnt/usbdrivein your file manager or terminal. You can now read, copy, and write files freely. - When finished, always unmount the drive safely before physically removing it:
sudo umount /mnt/usbdrive
Inspect and Repair Corrupted Filesystem Blocks Using fsck
If the USB drive was physically disconnected during a file write, corrupted filesystem superblock structures will cause the mount daemon to exit with non-zero exit statuses.
- For FAT32 partitions (common on smaller flash drives):
sudo dosfsck -a -v /dev/sdb1 - For native Linux ext4 formatted drives:
sudo fsck.ext4 -y /dev/sdb1 - Allow the filesystem check utility to repair damaged allocation tables, then test mounting again.
Restart the Udisks2 Storage Daemon
If the underlying userspace storage service has crashed, restarting the daemon restores desktop hotplug detection.
- Restart the Udisks2 system service:
sudo systemctl restart udisks2.service - Check its operational status:
sudo systemctl status udisks2.service - Re-insert your USB drive; Ubuntu will now detect, mount, and open the drive smoothly.