Linux – Unable to write as root (but can as user)

linuxmountnfspermissions

I have an NFS/NIS based file system. NFS and NIS servers are on different physical machines. When we log into our head node home directories are automounted. When logged in as a user I can write changes in my home directory. However, when I su root and try and write to my home directory I get a permission denied error.

Any ideas? Directories are mounted as rw (from the output of mount)

10.1.1.11:/data1/home/alex on /home/alex type nfs (rw,addr=10.1.1.11)

On the NFS server the /etc/exports defines the mounted /home directory (which contains each users home directory) as rw. I have a feeling I remember reading about you can set a flag so mounted NFS directories cannot be written to as a root?

Best Answer

This is usually caused by the configuration on the NFS server. NFS servers will often map UID 0 (root) to another user such as "nobody" or "nfsnobody". You need to specify on the NFS server which clients are allowed root access to the mount. On Linux, you usually need to specify no_root_squash in the /etc/exports file where the export is defined.

For example:

/data1/home        <mynfsclient.ip.or.dnsname>(rw,no_root_squash)

or

/data1/home       rw,no_root_squash

After this is set up, unmount and remount the export on the client and you should be able to access it as root.

Related Question