You need to do two things:
- create an fstab entry, and
- set the automounter to run during system boot.
Set up fstab
The OS X fstab entry is almost identical to the linux fstab format. However, since you are talking about external drives then you need to use a unique identifier to identify the drive rather than the device id. The problem with using the device id (eg. /dev/disk2) is that any changes in the connected devices (adding or removing an external drive, adding a hub, etc) can change the order in which the devices are enumerated and thus changing the device id (eg. from /dev/disk2 to /dev/disk3 if you add a new drive).
An OS X fstab should look like:
Code:
# Fsck Pass Number
# |
# Dump Flag |
# | |
# Mount Options | |
# | | |
# Filesystem | | |
# | | | |
# Mount Point | | | |
# Filesystem Identifer from diskutil | | | | |
# | | | | | |
UUID=4236231D-1117-333F-8899-3235F9B8000E none hfs rw,auto 1 2
Where the fields in order are:
- first field is the unique device id,
- second field is the mount point. That is, where you want the device to mount such as /mounts/mydisk -- in this case "none" is specified with causes the drive to default to the /Volumes/<filesystem name> mount point,
- third field is the filesystem type,
- fourth field is the mount options,
- fifth field is the dump flag, and
- sixth field is the fsck pass number.
To find the UUID for a particular drive you should open the terminal and run
mount without any arguments to list the mounted filesystems and identify the device node for your external drive. The device node will be something like
/dev/disk1s3. Ensure that the device you identify is for your external drive and not your internal drives. Now, using the device node you found, run the command
diskutil info <device node> to obtain the UUID. For example, if your device node is
/dev/disk1s3 then you run the command
diskutil info /dev/disk1s3. In the list of information printed you will see a long UUID string. This is the UUID you need to use in your fstab file instead of the traditional device node entry.
Setting up a /etc/fstab file will ensure that drives will mount with your specified options when they are automounted. But an additional step must be performed to ensure that the automounter mounts the drives when the system boots.
Set automounter to run
Under OS X by default, external drives are only mounted when a user logs into the system on the console. Other systems such as linux and Solaris typically mount drives during system boot. This means that if you ssh into OS X then your external drives will not be mounted until someone logs into the console.
To change this default behavior you need to set a property on the system to ensure that the automounter runs when the system boots. To do so, open a terminal window and run the following command:
Code:
sudo defaults write /Library/Preferences/SystemConfiguration/autodiskmount AutomountDisks