9

A volume intended for use by my user was created at OS installation with root ownership and my user lacks write permissions.

Some solutions I've read about include:

  • changing ownership of the mount point with chown
  • adding group write permissions with chmod
  • adding user or users mount option in /etc/fstab.

What is the best practice for this situation, and what are the implications of each approach?

1
  • Love it when your exact question has been asked (and answered)!
    – sonyisda1
    Oct 25 '20 at 18:33
12

If it's in /etc/fstab then it will mount at boot. As only root has write permissions then you you'll need to modify it so that the user has those permissions. The best way is:

chown -R user /mnt/point

If the root group has write permission as well and you want another group to have it then you can use:

chown -R user:group /mnt/point

If the root group doesn't have write access, then you can use chmod next:

chmod -R 775 /mnt/point

That will give write permission to the group if it's not there and read and execute to everyone else. You can modify the 775 to give whatever permissions you want to everyone else as that will be specified by the third number.

To better cover what you asked in your comment below:

You can add the user option to /etc/fstab but that only allows the file system to be mounted by any user. It won't change the permissions on the file system which is why you need chown and/or chmod. You can go ahead and add the user option so that a regular user without sudo can mount it should it be unmounted.

For practicality, the best option here is chown as it gives the user the needed permissions instantly. The chmod command can be used afterwards if the permissions need to be modified for others.

3
  • The chown approach works, but requires authentication to mount (if unmounted after boot). I presume adding user or users to the fstab mount options would allow user mounting without authentication? What are the practicality and security considerations of each approach?
    – adatum
    Jul 13 '18 at 2:24
  • @adatum See my update. Jul 13 '18 at 6:23
  • Do you have to run chown after mounting the partition? My mount point began as owned by a non-root because I logged in as e.g. bobby and created /home/bobby/mnt/usb. ls -l confirmed bobby's ownership. But, after mounting, ls -l gave root for owner and group. I then had to 'chown -R bobby ~/mnt/usb' as mounted; only then did bobby get write permission. Is this the expected outcome or peculiar to my system (OpenWrt)? I believe it would improve the answer to specify whether in general the chown method is expected to work on a mount point as yet unmounted.
    – Catomic
    Aug 13 at 3:40

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.