I was trying to find a way to prevent certain volumes (partitions, in my case) from automatically mounting on startup/login. I wanted to set up a specific partition as an offline volume where I could keep a backup of certain files. The idea was to have it invisible (unmounted) to the OS, so that apps and other users couldn't modify what I had stored there, unless specifically called for (mounted).
According to The OpenDarwin FAQ, you can't pick and choose which volumes are mounted and which are not. Apparently the autodiskmountd daemon will attempt to mount any available filesystems it finds at startup. At present, there doesn't appear to be any way to modify this behavior. Disabling this daemon is probably not a good idea either, even though doing so would probably have allowed traditional methods (such as customizing /etc/fstab) to do the trick.
Read the rest of the article for the solution and more discussion on the question of unmounting just one partition of a volume.
NOTE: The discussion behind this tip is kinda long and hasn't been extensively researched. Nevertheless, it's presented here in hopes that it could provide the solution someone is looking for and that others may be able to fill in the gaps.
As the above-mentioned FAQ notes, the next best thing is to leave autodiskmount alone and explicitly unmount any unwanted volume instead. At this point, one might consider simply using the Finder to eject the unwanted volume. The problem is that the Finder's idea of unmounting a filesystem is to eject the device. So if you tried to remove a certain volume/partition from the Finder, it would happliy comply, and eject any other partitions on the same device as well!
Another line of reasoning would be to issue an unmount /Volume/unwantedvolume on startup/login. The nice thing about this method is that it relies on standard user-level tools and doesn't require modifying any files that may confuse or break things with later Apple Software Updates. And while this does appear to work, the problem is that it seems to confuse the Finder. My guess is that the Finder or some other abstraction layer needs to syncrhonize certain data structures on the volumes it sees. Thus, doing a device-level mount/unmount of volume does the trick at the BSD layer, but not for the Finder.
What I finally found was the undocumented disktool command. disktool appears to know how to cleanly mount or unmount individual partition volumes while keeping the Finder happy. The only problem is that it only works with device names, not volume names. This means that you'll need to get a particular volume's device name by issuing the df or mount command from the terminal. In my case, the the volume I wanted to unmount had the device name 'disk0s13' so I used:
/usr/sbin/disktool -p disk0s13 0(the zero after the device name is required). So what I ended up doing was creating a simple AppleScript:
do shell script "/usr/sbin/disktool -p disk0s13 0 > /dev/null"that I have set up as a login app.
/usr/sbin/disktool -m disk0s13(or whatever device node you're using) and the previously-unmounted volume partition will appear in the Finder. The disktool -m command appears to block; it won't return you to the command prompt without hitting Ctrl-C, but the volume will mount fine.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20020701083519750