Sunday, March 16, 2008

NFS Mapping and Mass Group Ownership Change

Right to the point: 2 Unix (AIX 5.3L) servers with NFS directory one needs to be mounted on the other. The catch? Both must have the same user & group, and both the user & group must have the same IDs.

Since the target server (NFS Client) must stay intact, I had to change the group ID (GID) on the other box, then apply the new ID to all the files & directories on the system.

I changed the GID from old to new using smitty, AIX's administration interface utility. Then I applied the following script to all files & directories on the NFS Server:
find / -group 206 -exec chgrp 320 {} \;


"find" will look for all files & directories with the old GID, which is 206*, and when found, it will run "chgrp" to change its group to 320.

* Since there is no longer a group name associated with the old GID, it shows as a number when "ls"

chgrp can take the group name: chgrp "groupname" -- but I used the numerical value anyway.

P.S.: I had a moronic idea of running chgrp recursively, that is:
find / -group 206 -exec chgrp -R 320 {} \;

Thank God, I had a wakeup call before running that, because if I did, it would change the GID of ALL files & directories under a directory that matched the old GID, so this would've changed directories & files that might have had a different GID.

After all that, mounting NFS worked like charm & I no longer had mapping issues. Mounting was done as:
mount blade6:/path/to/dir /path/to/dir


P.S.: mounting the directory, then running chown on it is a dumb idea, because it would change the GID on the NFS Server.

No comments: