NFS mounting with correct UID and GID

Discussion about using NAS on Linux and Unix OS.
Post Reply
First post
Posts: 1
Joined: Thu Jan 14, 2021 6:12 am

NFS mounting with correct UID and GID

Post by FarmerCzech » Thu Jan 14, 2021 6:27 am


I would like to share with you with my problem using NFS on QNAP. Let me explain my problem:

I have three computers 1) Old computer a, 2) Old computer b and 3) New computer.
Now I have created shared folders for some data from old computer a and b. These folders contains data for apache servers in this case and so on....
The next think I want to do is to mount these 2 shared folders on new computer and start thesse two apache servers on one computer.

The problem is, UID and GID on old computer a and b are different (but usernames are the same).

So the problem now is, how can I make these two shared folders mounted on new computer work with correct users and groups. Ofcourse I can set /etc/passwd and /etc/groups like on old computer a, but then the second folder from old computer b wont work (and same opositely).
I have found, that it should be possile to force sending usernames instead of UIDs from QNAP using this command: echo N > /sys/module/nfsd/parameters/nfs4_disable_idmapping
Unnfortunately this does not work, because everything is root then (and I dont know why, because usernames corresponds to username on both old computers). But even if this would work, I have found out, that creating new files on mount always uses UID and GID, so this would be useless anyway....

I have also tried to use idmapd somehow, but this didnt work as well (I dont know, if Im not doing something wrong) I have set the same domain names, then tried to set some static translations, but nothing.... I have also created id resolver in /etc/request-key.conf to make this idmapd work, but nothing...

Could someone help me with this problem or redirect me somewhere? Im starrting to be desperate.

Thank you

Getting the hang of things
Posts: 63
Joined: Tue Nov 10, 2015 6:56 pm

Re: NFS mounting with correct UID and GID

Post by CarbonPepper » Tue Jan 19, 2021 8:10 pm

ALL UID and GID numbers must match across your network. It will be necessary to align them. Don't mess with alternatives, it'll cause nightmares in the future.

Make the changes in /etc/passwd
Then you can chown wiith the same username on the client and it will update the UIDs to the fresh one.

So if Fred was UID 800 and all his files are owner: Fred (UID 800)
Change his UID to 1020, then run
sudo chown -R Fred:groupname /media/whatevemount

All Fred's files will be changed to Fred (UID 1020)

By the way, it's a good convention to avoid default UIDs. E.g. in Ubuntu, UIDs start at 1000. Which means on a new client install, whichever user you add first will get UID 1000. If you use 1000 as a 'live' user, you'll run into problems in the future. If you use 1020 onward, it's more sustainable.
TVS-471 with 4x WD Red 3Tb. Used for business. Stability valued over features.
Mix of clients: Ubuntu Linux, Mac OS, Windows 10.

Post Reply

Return to “Linux & Unix (NFS)”