A simple UNIXish method of maintaining NFS automount points under Mac OS X 10.3 (Panther).
Had to do some research on how to set up persistent remote automount points in OS X 10.3 (Panther). Let’s break that down.
- persistent – Mounts should survive restarts.
- remote – In this case, I'm mounting NFS volumes exported from a Linux box.
- automount – Automatically mount the volume when I access the local mount point and then unmount after some duration of not using it anymore.
A Google search for "OS X" automount nfs yields some good results that
pretty much all say the same stuff:
Using automount on OS X 10.3 means adding a bunch of crap to the NetInfo database using the NetInfo Manager tool.
Much longer descriptions of how to set things up using the GUI or a ton of
niutil commands are here:
- Using automount on Mac OS X
- Automounting Sharepoints at Startup
- Integrating Mac OS X in an NIS network
This was my first experience with NetInfo Manager and it pissed me off. I'm sure
the whole NetInfo thing has its merits (is it LDAP based?) but one of the key
strengths of UNIX systems is that most system configuration stuff is handled
using plain old text files. This may seem arcane to those accustomed to the
registry editor in Windows but the benefits of plain text configuration are
numerous. For one thing, you don’t use a half-ass'd GUI (NetInfo Manager) to
modify configuration, you use whatever your favorite editor is or string
together a couple of text processing tools such as grep, sed, awk, etc.
Anyway, I had a hell of a time trying to get my OS X box to automount remote NFS
volumes persistently. Usually, this is a simple matter of adding a few lines
to an /etc/fstab or /etc/auto.misc file. The simplest way I could find for
having this same capability in OS X is to use the niload and nidump
utilities to import and export the NetInfo data from and to plain text files
that look a lot like traditional fstab maps.
First, get root and dump the current set of mount definitions to a file:
$ sudo su -
Password: [your password]
# nidump fstab . > /etc/fstab
Note that this will result in a blank file if you haven’t configured any remote automounts.
Next, add a line for each mount point. Mine looks like this:
asha:/pub /Network/Servers nfs resvport,net 0 0
daishar:/pub /Network/Servers nfs resvport,net 0 0
daishar:/home/rtomayko /Network/Servers nfs resvport,net 0 0
Some explanation is in order.
The first column is the remote mount point. This can be anything you might pass to mount (see
man mountfor more info).The second column tells the automounter where to create a symbolic link (I think Mac people call these “Aliases”). The automounter creates a directory with the name of server, then a series of directories mirroring the mountpoints
dirname, and finally the symlink that points to the actual local mount point created by the automounter (usually somewhere under/private/var/automount). I use/Network/Serversas my base mount directory because then these things will show up in the Finder underNetwork:Servers.The third column is the type of filesystem you are mounting. This can be
afpfor AppleShare filesystems,cd9660for CDs,hfsfor HFS filesystems,msdosfor FAT and FAT32 (I think),nfsfor NFS filesystems,smbfsfor SMB (samba/windows shares) filesystems,udffor DVDs, andwebdavfor WebDAV filesystems. I haven’t tried anything but NFS to date but plan on taking a hard look at the webdav support in the near future.The fourth column contains options for mounting the filesystem. There are a whole slew of things that can be specified to tweak the mount. The two most important options are
resvportandnet.resvporttells the automounter to make the connection to the remote NFS server using a reserved (privileged port). Use this if you are mounting a box that is configured to reject requests coming from non-privileged ports. Thenetoption is what tells the automounter that the mount isn’t just a plain old static mount. If you don’t specify thenetoption, the mount will be persistent but static (i.e. always mounted).The next two columns aren’t important here. Just set them to zero.
Once you've tweaked up your /etc/fstab file, you will need to load it back
into the NetInfo database using the following command (note: we are still root):
# niload -m fstab . < /etc/fstab
You should now be able to go into the NetInfo Manager utility and see that
everything is in order under mounts. You should now be able to make changes
to your /etc/fstab file and load them into NetInfo using the same niload
command.
Discuss
This helped a lot! Thanks for posting it.
— Jake on Sunday, December 30, 2007 at 01:04 PM #
Leave a comment