NFS Network Drive Added to /etc/fstab, only root has permissions
Emily Wong
I want to mount a network drive on a NAS (Synology DiskStation) when my linux server (old headless desktop running Ubuntu 20.04.2 LTS) boots, and I want to make the share available to all users under /mnt. I plan to see if I can write a script to back up some files to this share regularly so that if anything happens to my server, my files are back up on my NAS.
I have set up the network share with NFS on the NAS (IP address of linux server has read/write, Squash: No mapping), created the share directory under /mnt, I mounted the share, copied a few files to it as my regular non-root user, checked the files were on the NAS. Everything worked great. I rebooted, and the mount was gone. I expected this and looked up how to have the system mount this share at startup. I added the following line to my fstab.
<nas_ip>:/volume1/share /mnt/share nfs user,rw,hard,intr 0 0I rebooted, went to /mnt, and attempted to "cd /share" and get "Permission denied".
Eventually getting frustrated, I switched to root (sudo -i) and "cd /share" worked perfectly. I even created a new folder directly on the NAS and verified it was visible via command line as root. The network share is mounting and working, but no user besides root has access.
Is there something else I need to do? As I understand it, the "user" option under fstab should give all users access to the mount. Am I doing something wrong?
Thanks!
21 Answer
To make files actually accessible, you could use the admin interface on your NAS to set their owner to your user ID on your Linux machine, or you could try the uid=... and gid=... mount options in the /etc/fstab entry; see man 8 mount:
1uid=value, gid=value and umask=value
Set the file permission on the filesystem. The umask value is given in octal. By default, the files are owned by root and not readable by somebody else.