Subvert the automounter

From OS X Scientific Computing

Jump to: navigation, search

You should not have to do this, but at one point, due to naive user error, I was unable to get non OS X filesystems to play nice with the automounter, so I came up with this. Your milage may vary.

To mount a filesystem from a remote NFS server without using the automounter, you need to do the following:

Edit /etc/auto_master and comment out the following line:

# /-                    -static

Create a mountpoint of your choosing.

You can do this anywhere, but I find making a directory a the root level to be the most convenient. For example, let's say we want to mount two filesystems that are being exported from another computer called Simpson with the domain name simpson.springfield.org. We'll assume it has the OS X filesystem structure, but any unix filesystem will behave analogously. The first filesystem we will want to mount will be the remote /Users directory, and the second will be /Volumes/Homer, as the computer simpson.springfield.org has a second hard-drive creatively named Homer. Hence we will create two mountpoint directories as follows:

sudo mkdir -p /nfs_mountpoint/Simpson  /nfs_mountpoint/Homer

Next we need to create the file /etc/fstab

with the following two lines in it:

simpson.springfield.org:/Users  /nfs_mountpoint/Simpson nfs -i,-P,-b 0 0
simpson.springfield.org:/Volumes/Homer  /nfs_mountpoint/Homer nfs -i,-P,-b 0 0

The first field is the domain name (it is safest to give the whole thing), and the second, separated by a colon, is the filesystem that has been exported. The third field is the corresponding mount point you just made, the fourth tells the system that this is an nfs device that is being mounted, and the remaining arguments control access and mounting protocols. man fstab and man mount_nfsfor details. The disk is read/write accessible by default, but the user's numerical uid (eg: 503) must be the same on both the host an client machine. (Be aware that if joe on the server has uid 503 and sarah on the client has uid 503, sarah will have read-write access to joe's files!) (OS X, and at least some GNU/Linux systems, assigns uid numbers sequentially to each new user, starting with 501. Other systems assign large random numbers, which makes the appearance of this sort of security anomaly (or hole) statistically much more unlikely.)

You can now mount the remote filesystems with the commands

sudo mount /nfs_mountpoint/Simpson
sudo mount /nfs_mountpoint/Homer

or to mount all at once, simply issue the command

sudo mount -a

I made a startup item to do this upon reboot.