How to set ownership of exFAT drive when mounting?
https://askubuntu.com/questions/1427782/how-to-set-ownership-of-exfat-drive-when-mounting
There are a number of threads on this topic, but I have tried every single answer/suggestion and still have had no luck. Up until a few weeks ago, my mount command worked as expected, which almost makes me think this is some sort of bug.
I have a Raspberry Pi, running the 64-bit OS:
Linux raspberrypi 5.15.61-v8+ #1579 SMP PREEMPT Fri Aug 26 11:16:44 BST 2022 aarch64
I have run the following command to install the required exFAT tools:
sudo apt-get install exfat-fuse exfat-utils
I have initialized a mount point with:
sudo mkdir /mnt/fhpro
My desired behavior is that the drive is able to be read and written to by members of a certain group. I understand I need to set ownership of the drive to the group when mounting it, as exFAT does not allow for file-specific permissions.
I have run the following commands to change ownership of the mount point itself:
sudo chown myusername /mnt/fhpro
sudo chgrp groupname /mnt/fhpro
I then mount the drive with the following command:
sudo mount -t exfat /dev/sda1 /mnt/fhpro -o uid=1001,gid=1003,rw,fmask=0002,dmask=0002
where 1001 and 1003 are the IDs of the desired user and group.
The command runs without error, and I am able to view the contents of the drive. However, the drive is owned by the pi user and group, not the user and group that were set. When I run ls -l /mnt/fhpro, I see the following output:
total 8192
drwxr-xr-x 2 pi pi 131072 Jun 27 14:11 randomdir
Additionally, ls /mnt -l reveals that the mount point itself has also switched ownership to the pi user.
Furthermore, I can not write to the directory, as touch /mnt/fhpro/test.txt results in:
touch: cannot touch '/mnt/fhpro/test.txt': Permission denied
I am at a loss for what is going on here. I had a similar mount command set in my /etc/fstab before, and the drive would always mount with ownership set as expected. Now, that is no longer the case.
Any ideas?
Edit:
The man page for mount.exfat here says:
uid=n Set the owner for all files and directories. The default is the owner of the current process.
I am running this command from the account that I would like to own the contents of the drive (i.e. not the pi user). So clearly something is up.