Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
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 Jan 18 '12 at 13:36

2 Answers 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.

share|improve this answer
    
my exports is : /var/nfs_drive 172.19.0.0/16(rw,no_subtree_check,no_root_squash) is it wrong? –  Roman Jan 18 '12 at 14:31

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|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.