Automatically mounting USB drives on Mac OS X

When plugging in an external USB drive on Mac OS X, it gets nicely mounted under /Volumes and appears on your desktop.

However, since I use my MAC mini as Slimserver machine for my squeezebox, I want this automount also to happen after boot, before a user is logged in.

This seems not to be so trivial. I’ve tried several mechanisms to obtain the automount feature, from scripts executed at boot time to modifiying the fstab. None provided an acceptable solution.

The final solution is fairly simple, however. Just execute:

sudo defaults write
   /Library/Preferences/SystemConfiguration/autodiskmount
   AutomountDisksWithoutUserLogin -bool true

And your USB drive will be mounted at boot time under /Volumes. It will even get the uid/gid of the current user when someone logs in to the machine.

Note: this has been tested on MAC OS X 10.4.