1

I’ve been reading a few posts about this, but still haven’t gotten any traction. I’m convinced I’m dealing with my options getting overridden.

Context

I have an exfat mounted drive on a Raspberry Pi 4. I have two users, root and dietpi.

I want to mount the exfat drive so that the user dietpi can read and write to all the files in the drive.

I’ve sudo apt install exfat-fuse, and I have a line in my /etc/fstab:

/dev/sda1 /home/dietpi/filerun/user-files/ auto fmask=0777,user,noauto 0 0

I understand that this lets me run mount /dev/sda as a non root user (as dietpi) which is great.

But then the permissions when I ls -l that directory are as follows:

drwxr-xr-x  9 root   root  131072 Mar 19 04:07 user-files

The file are there, root can read/write to them. But not dietpi - it can only read, as the permissions show. Note that before I mount, this is what ls -l shows:

drwsrwxrwx  9 dietpi   dietpi  4096 Mar 19 04:07 user-files

I understand that with exfat drives, it defaults to root when you mount a directory as exfat drives have no notion of permissions. I cannot chown user-files to dietpi, either after it’s mounted.

If I print mount, what’s interesting is that it shows fmask=0222,user=dietpi. So the user is not root, which is good, but the fmask is not what I expected it to be. Is it getting overridden?

$ mount
…
/dev/sdal on /home/dietpi/filerun/user-files type exfat (rw, nosuid, nodev, noexec, relatime, fmask=0022, dmask=0022, jocharset=utf 8, errors=remount-ro, user=dietpi)
1
  • 2
    This question doesn't seem to belong here - not specific to Raspberry Pi, should go to Linux community
    – Vadim
    Mar 19, 2023 at 19:09

2 Answers 2

1

The following worked, but ONLY after a restart (sigh..):

UUID=XXXX-XXXX /path/to/mnt/dir exfat users,exec,rw,suid,dev,atime,diratime,uid=1000,gid=1000,umask=000 0 0
1

I think that most of your questions could be resolved by a thorough reading of man mount.exfat-fuse. But as I read your question, it seems you've sussed the majority of it.

By way of explanation, the reason that exFAT is so strange in comparison to other file systems is that the file system design has no provision for metadata typically used to store ownership and permission data in other filesystems. In other words, all ownership and permission data is set at mount-time, and it cannot be changed without a re-mounting. chown attempts are flagged with an Operation not permitted error, while chmod attempts fail silently.

man mount.exfat-fuse explains the various parameters and options available for setting the mount-time permissions and ownership: umask, dmask, fmask for setting permissions, and uid and gid for ownership.

1
  • That’s a clear and detailed explanation. Thanks
    – Gregory
    Feb 21 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.