New in Leopard! With Mac OS X 10.5, the Finder now allows you to mount and unmount individual partitions. What follows is still useful if you want something command-line based though.

In the OS X Finder you can't mount (or unmount) a single partition of a drive -- when you try to mount a single partition, all partitions on the drive get mounted, and when you try to unmount a single partition, all partitions on the drive get unmounted. I find this to be inconvenient with external drives that are formatted into multiple partitions, because for safety I don't like to mount ones unnecessarily (like my backups partition). When they are mounted and have files open they are susceptible to damage if you accidentally unplug a FireWire cable, if you mistake one partition for another, if there's a power outage, etc.

New in Tiger! With Mac OS X 10.4, the Disk Utility application now allows you to mount and unmount individual partitions. What follows is still useful if you want something faster than loading up Disk Utility though.

In the Terminal, you can use Unix commands to mount and unmount partitions using disktool (type that alone in the Terminal and you'll see ways to use it). However, it is inconvenient to do so because you have to specify the filesystem device name, not the Finder name, and this name (such as /dev/disk1s10) can change each time you reboot.

How To Mount/Unmount Individual Partitions

I created a command that will allow you to mount a single partition using the Finder partition name:

disktool -l | egrep -i "Mountpoint = '', fsType = 'hfs', volName = '.*name" | cut -d\' -f2 | xargs -n1 disktool -m

Enter this command (substituting the name of your partition in the Finder where name appears above), and after about 20 lines of output (like "***Disk Appeared...") the partition you specify will be mounted. The command will mount the partitions that match the characters you enter, so you can either (a) type only the letters that differentiate a single partition, or (b) type letters that match multiple partitions with similar names. For example, I mount just my iTunes partition just by entering "it" since no other partition has those two characters (the match is case insensitive, though if you don't want it to be, enter the egrep without the -i). And I mount all my incrementally numbered partitions scratch 1, scratch 2, etc., by just entering "scratch".

Similarly, you can unmount a single partition without unmounting the others on that disk with the command:

disktool -l | egrep -i "Mountpoint = '/Volumes/.*name" | cut -d\' -f2 | xargs -n1 disktool -p

How To Install Automated Scripts

To avoid having to type those lines in all the time, you can put them into shell scripts. I created two, so now I can mount my partitions from the Unix command line (via the Terminal) with "mountpart name" and unmount them with "unmountpart name".

To create the shell scripts, download the following files and install them in your path:

This software is Copyright © 2004 John F. Whitehead and is free under the GNU Public License.

Don't forget to put them in a directory that's included in your PATH variable and make them executable (chmod 755 /path/to/scripts/* If you don't know how to do this, take a look at a Mac OS X tutorial that discusses Unix, or look at the first part of this macosxhints article.

Customize Them!

You can custom edit those scripts to only mount/unmount each of your partitions separately. For instance, I have mount iTunes and mount scratch. My mount iTunes script specifies the name of my iTunes partition in the place where the script specifies $1. My mount scratch script does the same thing, but because I don't specify which of my numbered scratch partitions to mount, it matches on and mounts all of them.

How To Mount/Unmount From The Finder

Once you have created these scripts, you can activate them easily from the Finder: change each filename to end with the extension .command (rather than .sh) and when you open them in the Finder they will execute from within Terminal.

Not only that, but if you drag each file's icon to the OS X window toolbar, it will always be just a click away. I even went one step further and changed the icon from the generic script one to the one from the Installer utility, which looks more like what its action is.