February 7, 2007

Mounting External Disk

Macs are easy to use. Everything is plug and play, really. Fun starts when you unplug... Or in this case, when you logout. That's when you notice that your shiny new external USB or FireWire hard drive (like one of those LaCie mini drives, which stack nicely under the Mac Mini) magically got unmounted and your SVN/MySQL/Oracle/whateverhaveyou stopped working. So how would you keep external drive mounted?

Problem such as this would not take more than 5 minutes to solve under Linux - just add an entry in /etc/fstab - but, under OS X, fstab is deprecated. It's not even there in the /etc directory. And adding it there is complicated by the fact that device name is not guaranteed to be the same after the reboot due to parallelism in the boot process.

So what would you do? You could use diskutil to list all available disks and their labels, find out device name for the disk, and mount it (which can be done by diskutil, too). Would make a nice shell script. But I found it is easier to just make OS X mount all disks regardless of whether user is logged in to the console or not. Done by changing system preferences with command:

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

Now, if only it were easy to find this gem! Thanks to mac OS X hints.

Posted by Vadim at February 7, 2007 8:28 PM

Is it just as "easy" to transport (for good) one's music and photos (i.e. the iPhoto and iTunes libraries), to the now, automatically mounting external disk?

Posted by: M. Mortazavi at April 16, 2007 5:17 PM