Sharing disks with Leopard

I can’t take any credit for this, that has to go to Tom Adams, but I know that at some point in the future I am going to need this information.

My solution was to buy leopard server ( just lazy I guess…), but this achieves the same thing with desktop leopard. Consider the following diagram.

mac-mini-timemachine-destination

The objective is to use an old mac mini as a time machine destination for a load of desktop apple servers on your network. To get this to work, the mac mini needs to mount the external drive at boot up, and share it on the network. Usually the disks are mounted when you log in, which would work by using remote desktop and logging onto the machine but having it mount and share the drives on boot is much more elegant.

Firstly, you need to get on the mac mini, and share the disks in system preferences (here I have shared tmp, but timemachine may be a better share name);

systemprefs-sharevolumes

Then you need to enable the external drive as a time machine destination

cd /Volumes/disk1/timemachine
touch .com.apple.timemachine.supported

Then you need to add a manifest entry to the StartUp items

$ cat /Library/StartupItems/ShareDisks/StartupParameters.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Documentation: http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/StartupItems.html -->
<plist version="1.0">
  <dict>
    <key>Description</key>
    <string>Share External Hard Disks</string>
    <key>OrderPreference</key>
    <string>None</string>
    <key>Provides</key>
    <array>
      <string>Share External Hard Disks</string>
    </array>
  </dict>
</plist>

$ cat Library/StartupItems/ShareDisks/ShareDisks

#!/bin/sh
. /etc/rc.common
 
StartService() {
    diskutil mount /dev/disk1s2
    diskutil mount /dev/disk1s3
    /usr/sbin/AppleFileServer
}
 
StopService() {
    diskutil umount /dev/disk1s2
    diskutil umount /dev/disk1s3
}
 
RestartService() {
    diskutil umount /dev/disk1s2
    diskutil umount /dev/disk1s3
    diskutil mount /dev/disk1s2
    diskutil mount /dev/disk1s3
    /usr/sbin/AppleFileServer
}
 
RunService "$1"

Now you need to make the ShareDisks script executable

chown -R root:root /Library/StartupItems/ShareDisks
chmod +x /Library/StartupItems/ShareDisks/ShareDisks

And your done – All very neat really.

1 Responses to “Sharing disks with Leopard”


Leave a Reply