Using Time Machine over iSCSI to a FreeBSD server

I’ve been using this solution since the time 8.0-RELEASE was still just a wet dream and other than the lack of the recover-during-install option from a local drive, it’s been rock solid.

Install the net/iscsi_target port. Enable it in rc.conf.

echo iscsi_target_enable="YES" » /etc/rc.conf

Edit the configuration to share a new device. My /usr/local/etc/iscsi/targets looks as follows:

extents file start length

extent0 /iscsi/iscsi-target0 0 320GB

target flags storage netmask

target0 rw extent0 10.1.2.3/32 The target file will be a sparse file, taking up no space and sucking up disk space as you write to it. Make sure you have the space available.

(Re)start the iscsi daemon.

/usr/local/etc/rc.d/iscsi_target start

Install globalSAN iSCSI Initiator for OS X. Configure the initiator on your Mac. System Preferences -> globalSAN iSCSI Under “Portals”, add your server using the default port number. Under “Targets”, mark the target it found for you and hit “Log on…” A prompt should come up saying you just connected a drive and that it’s not readable. Partition it however you want. I just used “Erase” and the default settings. Asking it to completely erase the device will fill your nice small sparse file, so only do that if you want it to take up all of the space. Head over to the Time Machine option in System Preferences, choose your shiny new drive and start going. This has been tested with FreeBSD 8.0-CURRENT, iscsi_target 20080207, OSX 10.5.4 and globalSAN iSCSI Initiator 3.3.0.43. iscsi_target is not bound to the kernel, so this should work just fine with anything that uses the netbsd iscsi_target code.

Update: If you get "target.c:1317: ***ERROR*** iscsi_write_data_decap() failed" and the backup fails it means that you've used GlobalSAN version 4.0.0.203 - downgrade to version 3.3.0.43 and everything should work"

Update 2: globalSAN doesn’t make a Lion/Mountain Lion compatible initiator. Boo.