Prevent a partition from mounting in OS X
If you have a specific volume on your Mac that you would like to keep from being edited when attached, here's how to protect it.
When you boot OS X or attach a hard drive, the system will automatically try to mount any available volumes so you can access or format them for use. However, there may be times when you don't wish this to happen.
For example, if you have a dual-boot setup such as OS X 10.7 on one partition and OS X 10.8 on another, then you may wish to prevent one boot volume from being easily modified and perhaps corrupted when you are in the other operating system.
To do this, you will need to make use of the system's filesystem table (fstab) file, which manages special circumstances for the mounting of volumes in the system. Using the fstab file, you can set a volume to either not mount, or mount in read-only mode so it cannot be modified.
First, open the Terminal (in the Applications > Utilities folder) and type "diskutil info" followed by a single space. Then drag the desired disk to the Terminal window, and you should see a full path to it complete, so it looks something like the following command:
diskutil info /Volumes/Snow\
Now press Enter to execute the command, and you should see a list of details about the drive. Locate the one called Volume UUID and select and copy this number.
Next, in the Terminal run the following command to edit the "fstab" file (you will be prompted for your password, which will not show when you type it):
sudo pico /etc/fstab
When done, a small editor will show in the Terminal. Enter one of the following lines, replacing "NUMBER" with the copied UUID from the prior command. Also, the use of "hfs" in these lines indicates the drive is in Apple's HFS format, so change it to "ntfs" or "msdos" for a drive that is formatted in NTFS or FAT32:
UUID=NUMBER none hfs rw,noauto
UUID=NUMBER none hfs ro
The first of these will prevent the drive from being mounted, but if you do mount it using Disk Utility or another means, then the drive will be read and writable. The second option will make the disk be treated as read-only, but it will still show up automatically in the Finder when you start your system.
When finished with the edit, press Control-O followed by Enter to save the changes, and then press Control-X to exit the editor.
To undo these changes, simply run the "sudo pico /etc/fstab" command in the Terminal again to edit the fstab file, and delete the lines you added.