Using ZFS as (an iSCSI) target for Mac OS X Time Machine

Inspired by this and then this blog entry, I thought it was now time for me to get my own experience with iSCSI.

Here’s the result:

  1. On my eco-friendly server running OpenSolaris 2008.11, I created a new ZFS volume (not a ZFS file system!) with iSCSI sharing switched on:
    $ zfs create -o shareiscsi=on -V 180G pool2/mac-tm
    cannot share 'pool2/mac-tm': iscsitgtd failed request to share
    filesystem successfully created, but not shared
  2. Well, that did not work well. Better search and install the iSCSI packages first:
    $ pkg search -rl iscsi | nawk '{print $NF}' | \
    nawk 'BEGIN{FS="@"}{print $1}' | sort -u
    $ pkg install SUNWiscsi SUNWiscsitgt
    DOWNLOAD                                    PKGS       FILES     XFER (MB)
    Completed                                    2/2       18/18     0.86/0.86
    PHASE                                        ACTIONS
    Install Phase                                  74/74
    PHASE                                          ITEMS
    Reading Existing Index                           9/9
    Indexing Packages                                2/2
  3. Then, I wanted to delete (destroy, in ZFS speak) and create the zvol again:
    $ zfs destroy pool2/mac-tm
    cannot destroy 'pool2/mac-tm': volume has children
    use '-r' to destroy the following datasets:
  4. OK, I understand that an automated snapshot had already been created in the meantime. Destroy the zvol with its snapshots, and create the zvol again:
    $ zfs destroy -r pool2/mac-tm
    $ zfs create -o shareiscsi=on -V 180G pool2/mac-tm
  5. Check if the shareiscsi property is on for our volume:
    $ zfs get shareiscsi pool2/mac-tm
    NAME          PROPERTY    VALUE         SOURCE
    pool2/mac-tm  shareiscsi  on            local
  6. List all defined iSCSI targets:
    $ iscsitadm list target
    Target: pool2/mac-tm
    iSCSI Name:
    Connections: 0
  7. Looks great! On the MacBook Pro running Mac OS X 10.5.6, I installed the globalSAN iSCSI initiator software (version from Studio Network Solutions, after downloading from this link.
  8. Then I rebooted the Mac (as required by the globalSAN iSCSI software).
  9. Next step was to mount the iSCSI drive:
    Mac OS X System Preferences
    a) Click on the globalSAN iSCSI icon to display its control panel:
    GlobalSAN iSCSI control panel #1
    b) Click on the + symbol in the lower left corner to get the following popup:
    GlobalSAN iSCSI control panel #2
    c) Enter the IP address or host name of the OpenSolaris server, leave the port number as it is, and enter the target name (the last column in the line starting with iSCSI Name: in the output of the iscsitadm list target command on your OpenSolaris server – in our case, it’s ), and press the OK button. The iSCSI control panel will then look like:
    GlobalSAN iSCSI control panel #3
    d) Click the Connected switch at the end of the iSCSI target line (the line which starts with iqn) to get the following popup:
    GlobalSAN iSCSI control panel #4
    e) Press the Connect button to connect to that iSCSI target. As we did not specify CHAP or Kerberos authentication, the connect will work without user and password. For a walkthrough and more on CHAP authentication, click this link.
    After pressing the Connect button, the control panel will look like:
    GlobalSAN iSCSI control panel #5
    At this time, the newly created volume will show up in Disk Utility. Note that I clicked on the Persistent button to build the connection again after a reboot – I didn’t try rebooting to check, but believe it will work.
  10. Then, I created a Mac OS X volume in Disk Utility.
    Disk Utility #1
    a) Click on the disk drive and then on the Erase tab, enter a new name for the volume (or leave it as it is), and press the Erase… button. The following screen will displayed to show the progesss:
    Disk Utility #2
    After the erase is completed, the new volume will show up in the left part of the Disk Utility (For this screen shot, I created the volume again after providing the name ZFS-180GB for the volume. Not sure if it’s possible to rename a volume without formatting it):
    Disk Utility #3
  11. Now the volume is usable in Time Machine.
    a) Click on the Time Machine icon in System Preferences to start its control panel:
    TM control panel #1
    b) Click on Change Disk to change the destination volume for Time Machine (the lock in the lower left corner has to be unlocked first to allow for the change):
    TM control panel #2
    c) Select the new volume and press Use for Backup. Then, just start the backup (or wait 120 seconds until it starts automatically):
    TM control panel #3
    Mac OS X Time Machine has started its first backup on a ZFS volume!

However, as always in my blog entries, this is no guarantee that it will always work as described, or that the backup and restore will also work after your next Mac OS X upgrade, or that there will be no errors or problems with such a setup. What I can tell you is that a simple restore attempt worked for me just as if I had done it from a USB disk!

Up to now, I have always disconnected the USB disk drive before closing the Mac’s lid so that a Time Machine backup would not be interrupted in the middle. Not sure what would happen if a Time Machine backup is running while you close the lid, so better read the docs and test it, or just always unmount Time Machine’s active volume before letting your Mac sleep.

And I discovered that if an iSCSI volume is mounted before closing the lid, the Mac Book Pro cannot transition into deep sleep mode with a power consumption similar to the switched off state. It somehow sleeps, but with rotating fan and a steady front LED. And in order to wake it up, I had to open and close the lid several times. So the steps to do before closing the Mac’s lid are:

  1. Eject (unmount) the volume (use the eject menu item after right-clicking on the volume’s icon on the desktop).
  2. Disconnect the iSCSI target (and all others) in the globalSAN iSCSI control panel in the Mac OS X System Preferences, by unmarking the tick in column Connected for all targets. A confirmation popup will be shown when unmarking the Connected tick.

After waking up your Mac next time, just tick the Connected mark in the globalSAN iSCSI control panel again and confirm the popup that will be shown. If you did not choose another destination disk for Time Machine in the meantime, Time Machine will recognize the iSCSI drive as a valid destination volume automatically and use it for its next scheduled backup.

BTW For an interesting article on how to use ZFS iSCSI sharing with a Linux client, please click here.

11 Responses to “Using ZFS as (an iSCSI) target for Mac OS X Time Machine”

  1. artp Says:

    Of course you have to create the pool first. Are there any limitations on the pool configuration?

  2. Bernd Finger Says:

    artp: You are right! In this case, pool2 has to exist before trying to execute the command mentioned in step 1. I am not aware of any limitations regarding the pool configuration.

  3. Andre T. Fraser Says:

    Interesting! What type of throughput did you get with this setup? Was that over a Gigabit network or wireless? I will fire up my Solaris vm on my MBP and see what happens.

  4. Bernd Finger Says:

    Andre: The 134.8 GB backup which I had started late in the evening (probably at about 22:00) finished at about 05:00 next morning. So this would mean 134.8*1024/(7*60*60) = 5.5 MBytes/s (100 MBit/s Ethernet).

  5. Peter Sladeczek Says:

    I found it necessary to remove/eject all media and network connection _before_ closing the lid anyway. In kind you decide to detach your MacBook while asleep it can hang your machine coming up again, when no network is available or disks are missing. Particularly at home when moving from the WLAN to a wired network (big house I have, too big for single WiFi access point 😉 the system hung completely. This is from my memory, so test yourself. Another problem occurred when I ran the target on a faulty disk (with no redundancy, was just a test): some file system operation (copy) got stuck and I could not recover other than by rebooting (!) both machines (Mac client and OSol server)!

  6. Stephen Says:

    Hi, thanks for this article. I have my iscsi target setup in Global San as you described but it’s not showing up in Disk Utility. Solaris shows a connection and no errors. Any idea what might be wrong?

  7. Stephen Says:

    After some more reading I found out that Global San does not work with Solaris 10/08. To bad it would have been sweet if it did…

  8. Mark Linton Says:

    I have almost the exact same setup, 2008.11 OpenSolaris, iSCSI target ZFS filesystem, but instead of the 100mb connection, I use the WLAN one. As you describe in your post everything seems to work great when its first setup – and to be honest I get way better performance to this drive than I do backing up to an AirDisk connected to an Apple Airport Extreme (100mb version).
    Here’s where the problem is and I’m not sure where to start troubleshooting/investigating this. The MBP I have is a laptop, so I need to be able to disconnect/reconnect to the network quickly and without extra steps, same goes for putting the computer to sleep.
    So after the first full backup was complete (over 80gb in a little under 10 hours over WLAN), the backupd process successfully backed up a very small amount of data the second attempt (128k) then the next attempt at a standard backup, the backupd process is stopping with the following message:
    "07/04/09 7:40:52 AM /System/Library/CoreServices/backupd[2998] Waiting for index to be ready (915 > 0) "
    And time machine reports that it is "Preparing to backup"
    I’m not sure if this is due to some behavior related to the iSCSI target or GlobalSAN driver, but I haven’t been able to get a backup to complete successfully since.
    Any help would be very appreciative.
    Thanks! – This is very cool btw.

  9. Bernd Finger Says:

    I found some interesting information when searching for the following in Google:
    backupd mac os x "Preparing to backup"
    Please also read "Mac OS X 10.5: Time Machine may display "Preparing" for a longer time". It also contains possible reasons for TM showing this message.
    BTW I also get the message "Preparing to backup" from time to time, and it can take very long until it disappears and the backup begins.
    What I try to avoid with my setup is to close the lid of my MBP when the iSCSI volume is still connected, as the Mac won’t go into deep sleep mode. But maybe the behavior is different when using a wireless connection (in my case, it’s Ethernet).
    Hope that helps…

  10. Jesper Says:

    A question. How does OSX Leopard handle iSCSI-attached volumes when coming back from sleep mode, for example when I close the lid on my macbook and opens it again. Will the volume be reattached automatically? If I was to put my iTunes library on an iSCSI-attached volume, close the lid and open it again. Will iTunes be confused etc?

  11. Jesper Says:

    Ah. I just read the WHOLE entry. My exact question is answered just at the bottom of the page, Sorry for not reading the page before commenting..,.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: