MacOSX: Automount external drives at boot

After spending about an hour trying to figure out why I can't mount disks from /etc/fstab in MacOSX 10.4 I finally figured it out.

MacOSX 10.4 ( and maybe lower ) doesn't use fstab anymore. Well not just fstab. The stupidest thing about this is that fstab is referenced in every man page related to mount but nowhere it says it does NOT work anymore. I guess apple didn't want to invest in updating the man pages, no one is reading them anyway, everyone is using the gui tool, etc...

MacOSX holds all this information about mounts, users, groups, passwords, services, protocols, hosts and other stuff ( that uses to be in plain text files on Unix ) in it's NetInfo database. The good news is that you can import the information from the Unix standard format plain text files into the NetInfo database and you have an easy way to do this over the command line.

To mount one or more external disks at boot you will simply import the fstab entries just by piping them to the niload command:

echo "echo "/dev/disk1s10 none hfs rw,auto"  > /etc/fstab  	
cat /etc/fstab | niload -m fstab /   	# load fstab in netinfo

At the next boot /dev/disk1s10 will be mounted to /Volumes/disk1s10's label.
The weird thing about this is that you can't just remove /etc/fstab after you import in NetInfo. If you do this will not work anymore. If you just put the info in fstab but not inport it with niload it will not work. You need to both have a valid /etc/fstab and import it in order for this to work.

Leave a Reply