9:12 - Monday, 21 April 2014

NFS Permissions Trouble

I have an NFS4 share and I need to use it for 2 remote machines However, folders that were created on machine 1 are not writeable for machine 2, giving the error “Permission denided”.

How should I configure NFS?

Also machine 2 may write to a folder that was created on machine 1 if only signed as root, but that way is wrong for me.

Write access for NFS has to be configured carefully:

  • First, the share definition in /etc/exports should allow writing (I’m sure this is already the case in your setup, but sharing the contents of your /etc/exports wouldn’t hurt), e.g.

    /srv/share *(rw,sync,all_squash)
  • Next, you should be aware as what user you access the NFS share on the server. In the example above, all remote users are mapped to one user (typically nfsnobody) on the NFS server. This user should have write access on your shared directory. You can chown the shared directory to fix this:

    chown -R nfsnobody:nfsnobody /srv/share
  • Also, if you’re working on a RedHat-like distribution, make sure your SELinux settings are correct. I’m not going into that now, as it depends on the specific distro/version you’re using.

Using NFS also requires that you map your User IDs (UIDs) and Group IDs (GIDs). If the IDs are not synchronized between servers, NFS will work fine but the NFS server will not allow access to those by processes on the NFS client.

Even if you ahve usernames and groups that are identically named, you must have mapped IDs because the UID and GID numbers matter, not the name.

Such as this line from /etc/passwd:

backmin:x:500:500:testy:/home/backmin:/bin/bash

The first number (3rd field) is the UID for that user. If the client server has a DIFFERENT value for that user, they can’t see what’s owned by the same username on the client.

Share

Advertisement

Comment