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
    PACKAGE
    pkg:/SUNWiscsi
    pkg:/SUNWiscsitgt
    $ 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:
    pool2/mac-tm@zfs-auto-snap:frequent-2009-01-23-12:15#
  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: iqn.1986-03.com.sun:02:3f4f551a-41ab-4a3a-adf9-ea3ce5c2789c
        Connections: 0
  7. Looks great! On the MacBook Pro running Mac OS X 10.5.6, I installed the globalSAN iSCSI initiator software (version 3.3.0.43) 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 iqn.1986-03.com.sun:02:3f4f551a-41ab-4a3a-adf9-ea3ce5c2789c ), 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.

Comments:

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

ArtP

Posted by artp on January 28, 2009 at 08:47 AM CET #

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.

Posted by Bernd Finger on January 28, 2009 at 08:56 AM CET #

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.

Posted by Andre T. Fraser on January 29, 2009 at 06:37 AM CET #

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).

Posted by Bernd Finger on January 29, 2009 at 06:56 AM CET #

Bernd,

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)!
P

Posted by Peter Sladeczek on January 30, 2009 at 01:44 AM CET #

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?

Posted by Stephen on March 23, 2009 at 03:54 AM CET #

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...

Posted by Stephen on March 24, 2009 at 03:12 AM CET #

Bernd,

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.

Posted by Mark Linton on April 07, 2009 at 09:50 AM CEST #

Mark,
I found some interesting information when searching for the following in Google:
backupd mac os x "Preparing to backup"
Please also read http://support.apple.com/kb/TS1516 "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...
Bernd

Posted by Bernd Finger on April 07, 2009 at 03:11 PM CEST #

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?

...Jesper

Posted by Jesper on July 22, 2009 at 04:28 AM CEST #

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..,.

...jesper

Posted by Jesper on July 22, 2009 at 04:40 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

blogfinger

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today