Diff for /wikisrc/tutorials/how_to_use_iscsi_to_support_an_apple_time_machine.mdwn between versions 1.2 and 1.6

version 1.2, 2012/02/05 07:14:36 version 1.6, 2019/04/15 18:51:24
Line 4 Line 4
   
 #  Overview   #  Overview 
   
 [Apple Time Machine](http://www.apple.com/macosx/what-is-macosx/time-machine.html) is a backup mechanism which uses an Apple [sparse](http://wiki.netbsd.se/How_to_use_iSCSI_to_support_an_Apple_Time_Machine#Sparse_Files) filesystem model, with extended attributes to store the files and directories of your OSX system as an incremental state. You can walk 'back in time' against the history of the filesystem and recover older versions of files, or files which have subsequently been deleted. Unlike a dump, its not a complete independent collection of files: it prunes back in time against what it knows has changed, and so cannot be relied on in the same way as offline disk or tape backup written in a rigorous system. Nor is it an archive: if you want to preserve something, you need to manage that independently of a time machine setup. But, having said that, its enormously useful and very user friendly, and lots of OSX users are very happy with it. Most of them use directly attached media like a firewire or USB disk, or an Apple appliance like the Time Capsule. However, it is technically possible to do Time Machine over a network, to a network-mounted filesystem.   [Apple Time Machine](http://www.apple.com/macosx/what-is-macosx/time-machine.html) is a backup mechanism which uses an Apple [sparse](http://wiki.netbsd.org/how_to_use_iscsi_to_support_an_apple_time_machine#Sparse_Files) filesystem model, with extended attributes to store the files and directories of your OSX system as an incremental state. You can walk 'back in time' against the history of the filesystem and recover older versions of files, or files which have subsequently been deleted. Unlike a dump, its not a complete independent collection of files: it prunes back in time against what it knows has changed, and so cannot be relied on in the same way as offline disk or tape backup written in a rigorous system. Nor is it an archive: if you want to preserve something, you need to manage that independently of a time machine setup. But, having said that, its enormously useful and very user friendly, and lots of OSX users are very happy with it. Most of them use directly attached media like a firewire or USB disk, or an Apple appliance like the Time Capsule. However, it is technically possible to do Time Machine over a network, to a network-mounted filesystem. 
   
 NetBSD does not support [HFS+](http://en.wikipedia.org/wiki/HFS_Plus) format filesystems directly in a way which can be exposed to an OSX host over the network. Normally, its UNIX filesystems are mounted on clients by protocols like [NFS](http://en.wikipedia.org/wiki/Network_File_System_%28protocol%29), or [SMB](http://en.wikipedia.org/wiki/Server_Message_Block), or [AFP](http://en.wikipedia.org/wiki/Apple_Filing_Protocol) (Apple File Protocol) through either the built-in facilities of [mount_nfs](http://netbsd.gw.com/cgi-bin/man-cgi?mount_nfs++NetBSD-5.0), [mount_smb](http://netbsd.gw.com/cgi-bin/man-cgi?mount_smbfs++NetBSD-5.0) or a package like [netatalk](http://pkgsrc.se/net/netatalk). These are all provided by userspace daemons.   NetBSD does not support [HFS+](http://en.wikipedia.org/wiki/HFS_Plus) format filesystems directly in a way which can be exposed to an OSX host over the network. Normally, its UNIX filesystems are mounted on clients by protocols like [NFS](http://en.wikipedia.org/wiki/Network_File_System_%28protocol%29), or [SMB](http://en.wikipedia.org/wiki/Server_Message_Block), or [AFP](http://en.wikipedia.org/wiki/Apple_Filing_Protocol) (Apple File Protocol) through either the built-in facilities of [[!template id=man name="mount_nfs" section="8"]], [[!template id=man name="mount_smbfs" section="8"]] or a package like [netatalk](http://pkgsrc.se/net/netatalk). These are all provided by userspace daemons. 
   
 If you want to use these, there are documented ways to do this, such as the [apple time machine freebsd in 14 steps](http://blogs.freebsdish.org/rpaulo/2008/10/04/apple-time-machine-freebsd-in-14-steps/) page Rui Paulo wrote. They each have advantages and disadvantages, noting the need for special file support and extended attributes. Its probable that making the correct Apple sparse filesystem as a single file image, and moving this to the network-backed filestore gets round most of the problems, if you set the correct magic flag in your OSX to permit non-standard filesystems to be used to 'home' the time machine.   If you want to use these, there are documented ways to do this, such as the [apple time machine freebsd in 14 steps](https://web.archive.org/web/20081008055929/http://blogs.freebsdish.org/rpaulo/2008/10/04/apple-time-machine-freebsd-in-14-steps/) page Rui Paulo wrote. They each have advantages and disadvantages, noting the need for special file support and extended attributes. Its probable that making the correct Apple sparse filesystem as a single file image, and moving this to the network-backed filestore gets round most of the problems, if you set the correct magic flag in your OSX to permit non-standard filesystems to be used to 'home' the time machine. 
           
 defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1      defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
           
   
 However, the NetBSD [iSCSI](http://en.wikipedia.org/wiki/ISCSI) implementation is robust, and efficient, and will provide arbitrary client-side filesystems (such as HFS+, or Windows filesystems) because its presenting SCSI disk as raw blocks. These raw blocks are typically provided from a [sparse](http://wiki.netbsd.se/How_to_use_iSCSI_to_support_an_Apple_Time_Machine#Sparse_Files) file, in the NetBSD filesystem tree.   However, the NetBSD [iSCSI](http://en.wikipedia.org/wiki/ISCSI) implementation is robust, and efficient, and will provide arbitrary client-side filesystems (such as HFS+, or Windows filesystems) because its presenting SCSI disk as raw blocks. These raw blocks are typically provided from a [sparse](http://wiki.netbsd.org/how_to_use_iscsi_to_support_an_apple_time_machine#Sparse_Files) file, in the NetBSD filesystem tree.
   
 iSCSI talks about [targets](http://en.wikipedia.org/wiki/ISCSI#Target) (which is what a provider of an iSCSI disk is) and [initiators](http://en.wikipedia.org/wiki/ISCSI#Initiator) (which is what a client connecting to a given target is). -In this situation, NetBSD will be running as the target, via the [iscsi-target][23] daemon. The client has to have an initiator, which can present the target as a device.   iSCSI talks about [targets](http://en.wikipedia.org/wiki/ISCSI#Target) (which is what a provider of an iSCSI disk is) and [initiators](http://en.wikipedia.org/wiki/ISCSI#Initiator) (which is what a client connecting to a given target is). -In this situation, NetBSD will be running as the target, via the [[!template id=man name="iscsi-target" section="8"]] daemon. The client has to have an initiator, which can present the target as a device. 
   
 In order to use this on OSX, you need an iSCSI initiator. One which is freely available is Studio Network Solutions [globalSAN iSCSI initiator](http://www.studionetworksolutions.com/products/product_detail.php?t=more&pi=11) for OSX. At the time of writing, the version which works for me on Snow Leopard is 3.3.0.43 which is distributed as a ZIP'ed DMG file.   In order to use this on OSX, you need an iSCSI initiator. One which is freely available is Studio Network Solutions [globalSAN iSCSI initiator](http://www.studionetworksolutions.com/products/product_detail.php?t=more&pi=11) for OSX. At the time of writing, the version which works for me on Snow Leopard is 3.3.0.43 which is distributed as a ZIP'ed DMG file. 
   
 #  Initialize a target   #  Initialize a target 
   
 To create a target, you edit the [/etc/iscsi/target](http://netbsd.gw.com/cgi-bin/man-cgi?targets+5+NetBSD-5.0) file.   To create a target, you edit the [[!template id=man name="targets" section="5"]] file. 
   
 The default example shipped with NetBSD 5.0 and later is:   The default example shipped with NetBSD 5.0 and later found in `/etc/iscsi/targets` is: 
           
     # $NetBSD: how_to_use_iscsi_to_support_an_apple_time_machine.mdwn,v 1.1 2011/11/20 20:55:21 mspo Exp $#      #
     # Structure of this file:      # Structure of this file:
     #      #
     # + an extent is a straight (offset, length) pair of a file or device      # + an extent is a straight (offset, length) pair of a file or device
Line 48  The default example shipped with NetBSD  Line 48  The default example shipped with NetBSD 
           
   
       
 The target should be the name of a file in the filesystem you want it to reside in. When the iscsi-target daemon first runs over this configuration, targets are initialized as UNIX sparse files. Be very careful *not* to touch this file with a cp or any other operation which tickles NetBSD into filling in the 'holes' in the sparce file: dump and tar should be safe, as is rsync if the -S flag is given to it. (see [sparse files](http://wiki.netbsd.se/How_to_use_iSCSI_to_support_an_Apple_Time_Machine#Sparse_Files) below.)   The target should be the name of a file in the filesystem you want it to reside in. When the iscsi-target daemon first runs over this configuration, targets are initialized as UNIX sparse files. Be very careful *not* to touch this file with a cp or any other operation which tickles NetBSD into filling in the 'holes' in the sparce file: dump and tar should be safe, as is rsync if the -S flag is given to it. (see [sparse files](http://wiki.netbsd.org/how_to_use_iscsi_to_support_an_apple_time_machine#Sparse_Files) below.) 
   
 The /etc/iscsi/target file can implement simple ACL models for the IP network/prefix of the client(s) you wish to permit. The default in this file as distributed is a fully open iSCSI target. There is an associated /etc/iscsi/auth file which can be used to instantiate CHAP and other protections over the iSCSI attachment by the client.   The `/etc/iscsi/target` file can implement simple ACL models for the IP network/prefix of the client(s) you wish to permit. The default in this file as distributed is a fully open iSCSI target. There is an associated `/etc/iscsi/auth` file which can be used to instantiate CHAP and other protections over the iSCSI attachment by the client. 
   
 Be warned that the target name *has* to include a digit which will be translated to the SCSI 'LUN' number of the device for the client. Unless you know what you are doing, its best to leave this as 0 since the client may well demand only LUN0 is used.   Be warned that the target name *has* to include a digit which will be translated to the SCSI 'LUN' number of the device for the client. Unless you know what you are doing, its best to leave this as 0 since the client may well demand only LUN0 is used. 
   
 Once you have configured a target, you need to enable and start the [iscsi-target](http://netbsd.gw.com/cgi-bin/man-cgi?iscsi-target++NetBSD-5.0) daemon. Edit /etc/rc.conf and enable iscsi-target=YES, and then you can run /etc/rc.d/iscsi_target start (it will start automatically on reboot once enabled in /etc/rc.conf)   Once you have configured a target, you need to enable and start the [[!template id=man name="iscsi-target" section="8"]] daemon. Edit `/etc/rc.conf` and enable `iscsi-target=YES`, and then you can run `/etc/rc.d/iscsi_target start` (it will start automatically on reboot once enabled in `/etc/rc.conf`) 
   
   
 #  Install iSCSI initiator   #  Install iSCSI initiator 
Line 101  Once this is completed, the disk is a no Line 101  Once this is completed, the disk is a no
   
 A sparse file is a special file-type which reports its 'size' in ls -l as the total it could be, if it was fully populated. However, until actual file blocks at given offsets are written, they aren't there: its a linked list. This permits a very fast growable file to a limit, but at some risk: if you accidentally touch it the wrong way, it fills in the holes. You just have to be careful. FTP for instance, doesn't honour sparse files. if you copy a file with FTP, the holes are filled in.   A sparse file is a special file-type which reports its 'size' in ls -l as the total it could be, if it was fully populated. However, until actual file blocks at given offsets are written, they aren't there: its a linked list. This permits a very fast growable file to a limit, but at some risk: if you accidentally touch it the wrong way, it fills in the holes. You just have to be careful. FTP for instance, doesn't honour sparse files. if you copy a file with FTP, the holes are filled in. 
   
 Sparse files were implemented in UNIX FFS a long time ago, and are in HFS+ as well. The behaviour of the tools like pax, rsync, tar, ftp has to be verified on a case-by-case basis. Its not clear if NetBSD [pax](http://netbsd.gw.com/cgi-bin/man-cgi?pax++NetBSD-5.0) is safe or not. [rsync](http://pkgsrc.se/net/rsync) has the -S flag to preserve sparse files.   Sparse files were implemented in UNIX FFS a long time ago, and are in HFS+ as well. The behaviour of the tools like pax, rsync, tar, ftp has to be verified on a case-by-case basis. Its not clear if NetBSD [[!template id=man name="pax" section="1"]] is safe or not. [rsync](http://pkgsrc.se/net/rsync) has the -S flag to preserve sparse files. 
   

Removed from v.1.2  
changed lines
  Added in v.1.6


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb