-1

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.

Kenny Rasschaert
  • 9,045
  • 3
  • 42
  • 58
Roman Iuvshin
  • 131
  • 2
  • 8
  • 2
    What mechanism are you using to synchronize your UIDs and GIDs between the machines: manual passwd file edits, NIS, LDAP, or something else? – Magellan Jan 18 '12 at 13:20
  • You also should run 'mount | grep -i nfs' and provide that information. – Magellan Jan 18 '12 at 13:23
  • 172.19.20.151:/var/nfs_drive on /mnt/plf type nfs4 (rw,lock,proto=tcp,addr=172.19.20.151,clientaddr=172.19.20.51) – Roman Iuvshin Jan 18 '12 at 13:36

2 Answers2

2

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.

0

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.

Magellan
  • 4,451
  • 3
  • 30
  • 53