Skip to main content

Changing your User-ID on MacOS X to NFS mount from a unix server

··3 mins

The best way to use a remote directory from a unix server with MacOS X is via NFS. However, NFS uses the internal user ID number for access permissions. Thus, one must match UID’s on both the client and server. One must either change the ID on the server or the client, or both, depending on what your ID number is: MacOS starts numbering users at 501. It is important for the login widget GUI to work properly that the UID you change to is at least that high.

I started by following the directions here. However, there are a couple of more things to note, so I shall describe how I did it here.

My server is running FreeBSD, so I find my user ID number by logging into it and running the id command. The output says my uid=1002 so that’s what I’ll use for my Mac.

First, you need to do this all while not logged in as yourself. The easiest way to do this is to enable remote login via the Sharing preference panel, and log in from another server as root. To enable root login, run sudo su and then type passwd root and enter the new password. This is also a good time to note your existing UID on the Mac: niutil -read . /users/vivek|grep ^uid will display what it is. If you are the first user on the Mac, chances are it is 501 like it was for me.

Once logged in as root from another machine (and not logged in locally as yourself), you change your user ID with this command:

niutil -createprop . /users/vivek uid 1002

where vivek is replaced with your own login name. This updates your user ID in the system.

Now you need to change all file ownership of your existing files to your new ID. This is done with a simple find command (this may take a while):

find / -user 501 -print0 | xargs -0 chown vivek

There are a handful of files that are based on your UID, so you may wish to clean them up. Look in the /.Trashes and /Library/Caches directories (and subdirectories of these) for such files. You may need to re-set your login picture, so think about saving it first if it is not a standard one.

Now you can log in as yourself and NFS mount any directories from the server using the same ID. See this page for some more details.

This is also a good time to run the Disk Utility and have it fix permissions on your drive.

You will also want to run the NetInfo Manager and create groups to match the group IDs on your NFS server so that file listings show up properly. This is done as follows:

  1. Run NetInfo Manager
  2. click the lock icon to authenticate yourself
  3. select the groups entry
  4. select Directory -> New Directory
  5. in the property list in the lower half of the window, change new_directory to the name of the group, for example user
  6. select Directory -> New Property
  7. set the name of the property to gid and the value to the numeric value to match the group on the server, for example 100
  8. click the lock icon and agree to save the changes.

Repeat adding groups as necessary to match those on the NFS server that are in your mounted directories.

The only major issue encountered after this transition is that iSync lost all configuration information, so had to be reset and re-sync’d with both .Mac and my cell phone. The cell phone resync was a big botch, but I went in and manually cleared all the duplicate entries. I blame Motorola for their crappy cell phone software.