Fix USB Drive Permission Denied on Raspberry Pi¶
If a USB drive is visible but an app cannot write to it, first confirm the drive is mounted where the app expects it. Then check the filesystem type and the account doing the writing. For ext4, check the permissions on the data directory. For exFAT or FAT32, check the owner and modes assigned at mount time.
Check the USB mount and the failed path¶
Replace /mnt/usb-data with your drive's exact mount point. Use the actual data directory in the second command, or its parent if it could not be created.
- No mount row. Check
lsblk -o NAME,TRAN,FSTYPE,UUID,MOUNTPOINTSand use the actual mount point. An existing directory can be on the Pi's system disk when the USB drive is absent. Mount a USB drive at boot - Mount shows
ro. Find out why the mount is read-only before changing permissions. Diagnose a read-only file system - Mount shows
rw. Use itsFSTYPEto choose the next check. For a systemd service, use the service account. For a container, check the process's UID and GID and whether its bind mount is read-only.
On ext4, grant access to the data directory¶
namei -l shows the owner, group and mode of every component in the path. The account needs search permission (x) on each parent directory, plus write and search permissions (w and x) in the directory where it creates files. Linux path permissions
On the Pi 4B, a temporary ext4 directory at mode 0550 rejected writes from its owner. Mode 0750 allowed them. Removing search permission on its parent blocked writes again, even with the writable directory mode intact.
For a new application, create a dedicated directory owned by the account that will write to it. Replace YOUR_USB_UUID with the verified USB partition UUID and alex with the actual account. Choose an unused directory name.
Test local writes as that account after setup. This creates and removes one uniquely named empty file.
If the test succeeds but the app still fails, check its mount and permissions in the app's own environment. A read-only media library, for example, needs directory search permission and file read permission. Jellyfin USB media library · Samba share permissions
On exFAT or FAT32, set the owner at mount time¶
Linux assigns ownership and permissions for these filesystems from the mount options. Find the intended account's numeric IDs with id -u alex and id -g alex. For a drive mounted through /etc/fstab, the example below gives the owner write access and the group read access. Substitute your IDs, UUID and mount point. Use vfat as the filesystem type if that is what findmnt reports for your FAT32 drive.
dmask and fmask remove permission bits from directories and files. Here they give directories mode 0750 and regular files mode 0640. Validate the edited fstab, close applications using the drive, then unmount and mount the intended drive again. Confirm its UUID and options before repeating the write test. Linux exFAT mount options · FAT mount options