LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-28-2019, 05:29 AM   #1
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
Writing/reading from/to NetApp NFS volume with the same users, but different uid/gid


Hello, we have a netapp nfs volume mounted on 2 machines. Both machine use the same user/grouo to write/read from this volume, but when this users are/where created they didn't get the same uid and gid. Now, if one of the server write to the NFS volume, the other server wont be able to read/write for the exact file.

Any idea how to fix it? Also, we don't really have access to the netapp nfs volume, we only get it to use it.
 
Old 11-28-2019, 07:30 AM   #2
voleg
Member
 
Registered: Oct 2013
Distribution: RedHat CentOS Fedora SuSE
Posts: 354

Rep: Reputation: 51
When using NFSv4 , a username/groupname used instead of uid/gid.
You should configure NetApp and clients authenticates against same authority and you will get what you want.
It is a nightmare even in documentation, I never did it.
So, just fix uid/gid on one of servers and forget about v4.
 
Old 11-28-2019, 07:57 AM   #3
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Original Poster
Rep: Reputation: 73
Quote:
Originally Posted by voleg View Post
When using NFSv4 , a username/groupname used instead of uid/gid.
You should configure NetApp and clients authenticates against same authority and you will get what you want.
It is a nightmare even in documentation, I never did it.
So, just fix uid/gid on one of servers and forget about v4.
Are you refering to make sure all uids/gids are identical on both servers? If is that what you mean, is not really possible. The machines are already setup with the application and its very difficult to do that at this moment in time.
 
Old 11-28-2019, 08:24 AM   #4
voleg
Member
 
Registered: Oct 2013
Distribution: RedHat CentOS Fedora SuSE
Posts: 354

Rep: Reputation: 51
I did that not once.
Stop services, fix /etc/group and passwd.
Then run find , like:
Code:
# find / -gid OLDGID -exec chgrp GROUPNAME "{}" \;
# find / -uid OLDUID -exec chown USERNAME "{}" \;
These commands are dangerous, check them somewhere before run. Please also consider backup.
Also umount any remote system.
Probably using more narrow /home in "find" command will be much better than /.

Once finished, start services back.

Last edited by voleg; 11-28-2019 at 08:29 AM.
 
Old 11-30-2019, 04:10 AM   #5
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,792

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
Posix-compliant chown/chgrp need -h option, otherwise they follow symlinks!
They accept multiple file names, so you can speed up with + instead of \;
Code:
# find / -group OLDGID -exec chgrp -h NEWGID "{}" +
# find / -user OLDUID -exec chown -h NEWUID "{}" +

Last edited by MadeInGermany; 11-30-2019 at 04:19 AM. Reason: Added example
 
Old 11-30-2019, 10:28 PM   #6
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
If you absolutely can't change the UIDs and GIDs, there's a way to deal with this, but it's VERY dirty, and I wouldn't recommend it at all - largely posting for completeness' sake.

Suppose on server1 the app runs as UID U1 and GID G1 and on server2 it runs as UID U2 and GID G2. You will have to do the following -

1. On server1, create a group G1a (the name doesn't really matter) with the same GID as G2 on server2. Likewise, on server2, create a group G2a with the same GID as G1 on server1.

2. Add U1 to the G1a group on server1 and add U2 to the G2a group on server2.

3. Using whatever mechanism is required by your app - set the umask to 007 (or 002 if the files are supposed to be word readable). Generally this means putting the "umask 007" command in U1 and U2's .bashrc files or editing the init scripts of your application to set the umask explicitly.

Restart the application, From server1's perspective, files created on server2 should be owned by U2/G1a, but since U1 is in the G1a group and the files are group readable and writeable (assuming you did the umask trick right and the application didn't change the permissions out from under you), the app on server1 will be able to read and write them. Likewise for server2.

But seriously, why would you ever go into this trouble - it's confusing and fragile. It'd be far, far better to change the UIDs and GIDs to be consistent as suggested.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
UID GID from Centos6 to Centos7 : which consequences for uid 500 ? typierre2 Linux - Server 2 10-11-2019 08:23 AM
How to use SSHFS where UID===UID (same as NFS)? Lop3 Linux - Server 4 11-14-2015 08:13 AM
Automatically force all files in a directory to have the same UID/GID? fmillion Linux - General 3 04-23-2013 03:56 AM
Setting umask, gid and uid for NTFS-3G volume in KDE Media Manager ack_iix Slackware 1 03-14-2009 05:09 AM
is it legitimate and allowed and can be done to make another user account set uid and gid to null 0 to make another root account with different name and possibly not damage the debian system creating and using that new account BenJoBoy Linux - Newbie 12 01-29-2006 10:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration