I don't have permission to chown the mounted directory /mnt/hdd. I am currently logged in as root. The ls -l output is:

rwxrwxrwx 1 root root 131072 Jan  1  1970 hdd

I am mounting it via fstab config:

/dev/sda1 /mnt/hdd exfat-fuse defaults 0 0

I am trying to assign the owner of that drive to www-data via that command:

root@owncloud:/mnt# chown -R www-data:www-data hdd

and it says I don't have permission to do that.

mount command output:

/dev/sda1 on /mnt/hdd type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
  • Do include the actual error message from chown. It may or may not be important in this particular question, but in general it's always better to include it than to not include error messages. – Kusalananda Nov 3 '18 at 13:15

/mnt/hdd is an ExFAT filesystem, which does not actually have a concept of Unix-style file ownerships nor permissions, and so cannot store them. This is why your chown command is failing.

The ownerships and permissions displayed by ls -l are actually created on-the-fly by the exfat-fuse driver according to the mount options. Since the default list of mount options includes allow_other, the driver is currently allowing full access to all the files and directories in this filesystem to any user on the system.

You could use the id www-data command to display the user and group ID numbers of the www-data user. If the www-data has UID of 33 and primary GID of also 33, you could change your /etc/fstab line to:

/dev/sda1 /mnt/hdd exfat-fuse default_permissions,allow_root,uid=33,gid=33,nosuid,nodev,relatime,blksize=4096 0 0

Then unmount & re-mount the filesystem:

umount /mnt/hdd
mount /mnt/hdd

Now all the file and directory ownerships and permissions in the /mnt/hdd filesystem should have changed.

Note that this kind of Unix ownership and permission emulation for filesystems that don't have the capability to store Unix-style ownership/permission information is restricted to what you can specify with mount options: usually, it means that all the files and all the directories in that filesystem will have a single, fixed set of ownership/permission settings and they cannot be changed with chown/chmod commands at all. If this is too inflexible for you, I'm afraid the only option would be to use another filesystem type.

It this is a temporary setup, using an ExFAT filesystem to hold web server data (as indicated by the username www-data) might be fine. But if this is supposed to be a permanent setup, you should seriously consider reformatting /dev/sda1 to another filesystem type that allows native Unix-style file ownerships and permissions before starting to use it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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