3

I have a fresh install of ubuntu 22.04 and an external USB hdd formatted as exFAT. I can write to it as root but I can't write to it as a user. I'd like to allow all users the ability to write to this drive. If I try to add write permissions nothing changes.

Here's the relevant line from /etc/fstab:

/dev/disk/by-id/usb-Hitachi_HDS5C3020ALA632_FFFACFF0FD000000FF4221F302FD4F-0:0-part1 /media/external auto nosuid,nodev,nofail,x-gvfs-show 0 0

and here's some example console output illustrating my issue:

touch: cannot touch 'external/foo.txt': Permission denied
x@x-U4:/media$ ls -al
total 520
drwxr-xr-x  3 root root   4096 Feb  6 21:12 .
drwxr-xr-x 20 root root   4096 Feb  5 11:29 ..
drwxr-xr-x  4 root root 524288 Feb  7 22:52 external
x@x-U4:/media$ chmod 777 external
chmod: changing permissions of 'external': Operation not permitted
x@x-U4:/media$ sudo !!
sudo chmod 777 external
x@x-U4:/media$ sudo chmod 777 external
x@x-U4:/media$ ls -al
total 520
drwxr-xr-x  3 root root   4096 Feb  6 21:12 .
drwxr-xr-x 20 root root   4096 Feb  5 11:29 ..
drwxr-xr-x  4 root root 524288 Feb  7 22:52 external
x@x-U4:/media$ sudo chmod o+w external/
x@x-U4:/media$ ls -al
total 520
drwxr-xr-x  3 root root   4096 Feb  6 21:12 .
drwxr-xr-x 20 root root   4096 Feb  5 11:29 ..
drwxr-xr-x  4 root root 524288 Feb  7 22:52 external
x@x-U4:/media$ touch external/foo.txt
touch: cannot touch 'external/foo.txt': Permission denied
x@x-U4:/media$ sudo touch external/foo.txt
x@x-U4:/media$ ls external/*.txt
external/foo.txt

Any idea whats going on and how I can let users write to /media/external?

1 Answers1

3

To enable write permissions for all users, change the /etc/fstab line to the following.

/dev/disk/by-id/usb-Hitachi_HDS5C3020ALA632_FFFACFF0FD000000FF4221F302FD4F-0:0-part1 /media/external auto rw,user,uid=1000,dmask=0000,fmask=0000,nosuid,nodev,nofail,x-gvfs-show 0 0

ref: "dmask" and "fmask" mount options

Archisman Panigrahi
  • 28,338
  • 18
  • 105
  • 212
  • 1
    This answer combined with the explanation of the dmask and fmask got me to my answer. https://askubuntu.com/questions/429848/dmask-and-fmask-mount-options to get exactly what i wanted I didn't need the uid set and dmask and fmask need to be 000, though i decided to choose a slightly more conservative mask in the end – user1816847 Feb 08 '23 at 08:55
  • @user1816847 Feel free to edit the answer. That will help other people in the future. – Archisman Panigrahi Feb 08 '23 at 14:09