Prevent a given partition from mounting at boot

Oct 10, '06 07:30:00AM

Contributed by: emanuele

I have an external hard disk with two partitions on it: a principal partition is used for all my stuff (apps, games, user file, music, etc.), and a secondary partition with a minimal OS X installation, containing some diagnostic and recovering software utility, that I periodically use for backup and testing purposes.

The principal partition is obviously always active, but ideally the secondary partition would be inactive or hidden on boot, so that it no longer appears on my desktop and would be manually actived when needed (with Disk Utility, the command line or via a automated backup script). For example, I know that TechTool Pro does something similar and calls such partition "eDrive."

There are several hints on this site for unmounting a partition at login, but a better way to make this happen can be used. You need to create an entry point in your filesystem table to tell the OS not to mount that specific volume, and this is relatively easy. In Mac OS X, and under Linux and others unix systems, the volume mounting configuration file is located in /etc/fstab. This file in Mac OS X Tiger is empty (in Panther, it's commented), but type man fstab in Terminal to read some important information.

Read on for my solution...

An /etc/fstab example:

 # Identifier,  mount point,  fs type,  options1
 UUID=DF000C7E-AE0C-3B15-B730-DFD2EF15CB91  /export  ufs    ro
 UUID=FAB060E9-79F7-33FF-BE85-E1D3ABD3EDEA  none     hfs    rw,noauto
 LABEL=This40Is40The40Volume40Name  none     msdos  ro
The Identifier is used to identify the volume; the LABEL is the volume name, the UUID is the Universal Unique Identifier Drive. You can use both, but the UUID is the best choice because renaming the volume will not change this identifier.

The mount point is the directory used when the volume is mounted; set none to use the pre-defined OS X directory, i.e. ./Volumes/

The fs type describes the type of the filesystem; use hfs for a Mac volume. The field options describes the mount options associated with the filesystem. The option auto will mount the volume in the normal way, noauto will force the volume not to be mounted automatically; and last, use rw or ro for a read-write or read-only disk.

The UUID of a volume can be seen in Disk Utility (click the Info button and find the Universal Unique Identifier), or in Terminal using this command:
diskutil info /path/to/disk
In Mac OS X Panther, Disk Utility and the diskutil command doesn't display the UUID value. But if you look in the system.log file, when the disk is mounted, you can see something similar to this (line breaks added for narrower display):
 ... localhost diskarbitrationd[87]: disk1s9   hfs  
   77F3E84D-E0ED-3194-96A5-BED10893FFF4  FireWire HD    
   /Volumes/FireWire HD<br>
  ... localhost diskarbitrationd[87]: disk1s10  hfs  
   F0E430C1-5558-3BB3-9FA9-6904B663FEEA  Mac OS X Disc 
   /Volumes/Mac OS X Disc
The string before the volume name is the UUID for the disk.

Now that you have a UUID for the volume to hide during the mount process, from an admin account edit your /etc/fstab file:
 sudo pico /etc/fstab/
Add a line with the UUID for your volume and the mounting point information, for example:
 UUID=F0E430C1-5558-3BB3-9FA9-6904B663FEEA  none  hfs  rw,noauto
Save the file and reboot (for internal drives) or unmount, disconnect and reconnect the volume (for external drives). Now the system should not mount the partition identified in fstab. You can still manually mount the volume in Disk Utility, or via the command line (and for a volume containing a boot system, rebooting from it).

[robg adds: I haven't tested this one, and would recommend having a good backup before proceeding if you're going to do so.]

Comments (37)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20060930150059172