Can Linux mount a normal Time Machine sparse bundle disk image directory?
Solution 1:
You may use a combination of these two:
FUSE filesystem for reading Mac OS sparse-bundle disk images
- https://github.com/torarnv/sparsebundlefs
Apple's Time Machine fuse read only file system
- https://github.com/abique/tmfs
The first takes care of the .sparsebundle format, presenting it as a dmg file, which can then be mounted like normal. The second takes care of the directory hard-links used by Time Machine.
Solution 2:
This is an extension to the answer by @TorArneVestbø.
Once you have installed https://github.com/torarnv/sparsebundlefs and https://github.com/abique/tmfs you need to run the following script in Bash. Make sure to update the two variables at the beginning to be the source and destination.
SB="/path/to/your/Backup.sparsebundle"
TM_MNT="/path/to/where/to/mount"
# Make directories
mkdir -p "$TM_MNT"
SB_MNT=`mktemp --tmpdir -d sparsebundle_mnt.XXX`
SB_DMG="$SB_MNT/sparsebundle.dmg"
HFS_MNT=`mktemp --tmpdir -d hfsx_mnt.XXX`
# Mount the sparse bundle
sudo `which sparsebundlefs` "$SB" "$SB_MNT"
# Mount the HFS+ partition
OFF=`sudo parted "$SB_DMG" unit B print | tr 'B' ' ' | awk '/hfsx/ {print $2}'`
SZ=`sudo parted "$SB_DMG" unit B print | tr 'B' ' ' | awk '/hfsx/ {print $4}'`
LO=`sudo losetup -f "$SB_DMG" --offset $OFF --sizelimit $SZ --show`
sudo mount -t hfsplus -r "$LO" "$HFS_MNT"
# Mount the Time Machine filesystem
sudo `which tmfs` "$HFS_MNT" "$TM_MNT" -ouid=$(id -u $USER),gid=$(id -g $USER),allow_other
The final mount will be accessible by you (as long as $TM_MNT
is accessible to you). The final line may fail if FUSE is not setup to allow other user, it tells you how to fix it.
To unmount you need to do the following:
sudo umount "$TM_MNT"
sudo rmdir "$TM_MNT"
sudo umount "$HFS_MNT"
sudo rmdir "$HFS_MNT"
sudo losetup -d "$LO"
sudo umount "$SB_MNT"
sudo rmdir "$SB_MNT"
This was tested on a Fedora 28 system and is working well.
Solution 3:
Apple's Time Machine fuse read only file system
https://github.com/abique/tmfs
Solution 4:
The above post, from Alexandre Bicque, provides a Linux (?unix) program that will open a Time Machine sparsebundle stored on a Mac-formatted HFS+ disk or disk partition, allowing reading of the files on a Linux server.
Getting it set up isn't for the faint-hearted. It's written in C++ and requires 3 C++ libraries - cmake
, FUSE, and Boost, with certain minimum versions (which may not be default latest versions for my Ubuntu Server 10.04.) It also requires finding and installing a g++ compiler and the above libraries.
I use Ubuntu server 10.04 and am not much of a programmer. However, after a fair bit of work and time, I did manage to install all the necessary libraries, compile and link the tmfs package, and use it. It does work, allowing mounting a TimeMachine Time Capsule. HOWEVER, it does require that the disk on which the sparsebundle image is written be an HFS+ disk or partition. It won't work if the image is written on an NTFS or ext2/ext3/ext4 file system on a Linux server.
As of Apple's OS X 10.7 (Lion), Time Machine (sparsebundle) images will no longer work if mounted on a Windows (smb/Samba) Linux share, and it's necessary to run Linux/Unix Netatalk (afpd
plus avahi-daemon
) services to use Linux as a Time Machine server.
I've done a lot of looking for another solution. I suspect that a Linux/Unix C++ programmer could do better than have I, extending Alexandre Bicque's work to allow the use of ext4 or ntfs file systems. I'm trying to figure out how to do it, but have a long way to go.
I think it will require that I understand much better the fuse (user-space file system) and perhaps the boost::filesystem
system development helpers in order to move forward.
Solution 5:
Unfortunately the path to finding things in a sparsebundle from Linux is not straightforward. It can be done, but it requires interpreting some inode information that Apple embeds in the hardlinks to find the actual file in the sparsebundle. This MacWorld hint describes how you go about figuring out where a hardlink in a sparsebundle points to in terms of the actual file so you can access it from a Linux system. It deals with a Time Machine disk that's been attached as a local disk to a single machine.
In your case <mount point>/Backups.backupdb
is most likely <machinename>
.backupdb`.
I'm not sure whether <mount point>/.HFS+ Private Directory Data
exists in the same spot for a shared disk being used for Time Machine backups by multiple machines. You'll have to do a little ls -la
inspection of the disk and sparsebundles to find that.
But otherwise those MacWorld instructions will help you retrieve files on a Time Machine bundle, from Linux.
A update regarding the mount point.
I did some experimenting based on your updated question. It looks like the mount point should be the *.sparsebundle
directory and not the drive. If I mount the drive in OS X and the go to /Volumes/Remote Backups/mymachine.sparsebundle
I see the bands
directory like you do and it's useless.
But if I mount mymachine.sparsebundle
such that I can go to /Volumes/Time Machine Backups
(that's what it mounts as automatically in Finder when I double click on the mymachine.sparsebundle
) I see the expected Backups.backupdb
directory and under that the date-time directories as expected.