FUSE 2.9 added support for zero copy reads/writes through two new callbacks, read_buf and write_buf. We now imeplement read_buf, which iterates over the bands using the generic code, but instead of opening and reading the content of the band into memory, we just open the file and pass a structure back to FUSE with the file descriptor, size, and offset, and FUSE will then use this on the kernel side if possible (using splice on GNU/Linux). For padding with zeroes we open /dev/zero and treat it as any other file. Since FUSE does not provide a callback when it's done with the buffers there's no way for us to know when to close the bands we opened. To work around this we keep the files open until either the main image (dmg) file has been closed, or we run out of file descriptors, at which point we gc the open files and continue.
sparsebundlefs
FUSE filesystem for reading Mac OS sparse-bundle disk images.
Mac OS X v10.5 (Leopard) introduced the concept of sparse-bundle disk images, where the data is stored as a collection of small, fixed-size band-files instead of as a single monolithic file. This allows for more efficient backups of the disk image, as only the changed bands need to be stored.
One common source of sparse-bundles is Mac OS' backup utility, Time Machine, which stores the backup data within a sparse-bundle image on the chosen backup volume.
This software package implements a FUSE virtual filesystem for read-only access to the sparse-bundle, as if it was a single monolithic image.
Installation
Clone the project from GitHub:
git clone git://github.com/torarnv/sparsebundlefs.git
Or download the latest tar-ball:
curl -L https://github.com/torarnv/sparsebundlefs/tarball/master | tar xvz
Install dependencies:
- OSXFUSE on Mac OS X
apt get install libfuse-dev libfuse2 fuse-utilson Debian-based GNU/Linux distros- Or install the latest FUSE manually from source
Compile:
make
Note: If your FUSE installation is in a non-default location you may have to
export PKG_CONFIG_PATH before compiling.
Usage
To mount a .sparsebundle disk image, execute the following command:
sparsebundlefs [-o options] sparsebundle mountpoint
For example:
sparsebundlefs ~/MyDiskImage.sparsebundle /tmp/my-disk-image
This will give you a directory at the mount point with a single sparsebundle.dmg file.
You may then proceed to mount the .dmg file using regular means, eg.:
mount -o loop -t hfsplus /tmp/my-disk-image/sparsebundle.dmg /mnt/my-disk
This will give you read-only access to the content of the sparse-bundle disk image.
Reading Time Machine backups
Time Machine builds on a feature of the HFS+ filesystem called directory hard-links. This allows multiple snapshots of the backup set to reference the same data, without having to maintain hard-links for every file in the backup set.
Unfortunately this feature is not yet part of mount.hfsplus, so when navigating the mounted Time Machine image these directory hard-links will show up as empty files instead of directories. The real data still lives inside a directory named .HFS+ Private Directory Data\r at the root of the volume, but making the connection from a a zero-sized file to its corresponding directory inside the secret data location is a bit cumbersome.
Luckily there's another FUSE filesystem available, tmfs, which will allow you to re-mount an existing HFS+ volume and then navigate it as if the directory hard-links were regular directories. The syntax is similar to sparsebundlefs:
tmfs /mnt/tm-hfs-image /mnt/tm-root
License
This software is licensed under the BSD two-clause "simplified" license.