1

I have a sparsebundle file that I pulled off of an old Time Machine backup disk. I'd like to save the file if possible, but remove the media files from it (movies, music, etc.) because those are elsewhere.

However, I cannot seem to figure out how to get it to be mounted RW and/or how modify the image in any way.

bash-3.2$ hdiutil pmap geek-imac.sparsebundle

MEDIA: ""; Size 2 TB [3902834784 x 512]; Max Transfer Blocks 2048
SCHEME: 1 GPT, "GPT Partition Scheme" [16]
SECTION: 1 Type:'MAP'; Size 2 TB [3902834784 x 512]; Offset 34 Blocks (3902834717 + 67) x 512
ID Type                 Offset       Size         Name                      (2)
-- -------------------- ------------ ------------ -------------------- --------
 1 EFI                            40       409600 EFI System Partition
 2 Apple_HFS                  409640   3902162960 disk image          
   Free                   3902572600       262151

I can mount it

bash-3.2$ hdiutil attach  -readwrite geek-imac.sparsebundle -shadow
/dev/disk3              GUID_partition_scheme           
/dev/disk3s1            EFI                             
/dev/disk3s2            Apple_HFS                       /Volumes/Time Machine Backups

Everything seems ok

bash-3.2$ hdiutil info
framework       : 480.60.2
driver          : 10.13v480.60.2
================================================
image-path      : /Volumes/Media-External/Old Time Machine Backups/geek-imac.sparsebundle
image-alias     : /Volumes/Media-External/Old Time Machine Backups/geek-imac.sparsebundle
shadow-path     : /Volumes/Media-External/Old Time Machine Backups/geek-imac.sparsebundle.shadow
shadow-alias    : /Volumes/Media-External/Old Time Machine Backups/geek-imac.sparsebundle.shadow
icon-path       : /System/Library/PrivateFrameworks/DiskImages.framework/Resources/CDiskImage.icns
image-type      : sparse bundle disk image (shadowed)
system-image    : false
blockcount      : 3902834784
blocksize       : 512
writeable       : TRUE
autodiskmount   : TRUE
removable       : TRUE
image-encrypted : false
mounting user   : geek
mounting mode   : <unknown>
process ID      : 15146
/dev/disk3      GUID_partition_scheme   
/dev/disk3s1    C12A7328-F81F-11D2-BA4B-00A0C93EC93B
/dev/disk3s2    48465300-0000-11AA-AA11-00306543ECAC    /Volumes/Time Machine Backups

bash-3.2$ mount
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
/dev/disk1s2 on /Volumes/Media-External (hfs, local, nodev, nosuid, journaled, noowners)
/dev/disk3s2 on /Volumes/Time Machine Backups (hfs, local, nodev, nosuid, journaled, noowners, mounted by geek)

But I cannot remove files

bash-3.2$ rm -f /Volumes/Time\ Machine\ Backups/Backups.backupdb/geek-imac/Latest/Macintosh\ HD/Users/geek/Movies/movie.m4v 
rm: /Volumes/Time Machine Backups/Backups.backupdb/geek-imac/Latest/Macintosh HD/Users/geek/Movies/movie.m4v: Permission denied
bash-3.2$ sudo rm -f /Volumes/Time\ Machine\ Backups/Backups.backupdb/geek-imac/Latest/Macintosh\ HD/Users/geek/Movies/movie.m4v 
Password:
rm: /Volumes/Time Machine Backups/Backups.backupdb/geek-imac/Latest/Macintosh HD/Users/geek/Movies/movie.m4v: Operation not permitted

How can I remove files from this sparsebundle image and/or convert (or even copy) this to a sparsebundle that supports modification?

2
  • Modifying a Time Machine backup using general tools (like rm) can corrupt it. TM sets special permissions (access control entries) on its backups to prevent this. I'm not sure exactly how to use it in this situation (hence this is a comment rather than an answer), but you probably need something like sudo tmutil delete /Volumes/Time\ Machine\ Backups/Backups.backupdb/geek-imac/Latest/Macintosh\ HD/Users/geek/Movies/movie.m4v. See the tmutil man page. Jan 17 '19 at 18:28
  • @GordonDavisson - I've used that command extensively to trim down the other backup folders, but it does not work for individual files. bash-3.2$ sudo tmutil delete ./movie.m4v /Volumes/Time Machine Backups/Backups.backupdb/geek-imac/2016-11-26-042049/Macintosh HD/Users/geek/Movies/movie.m4v: Invalid deletion target (error 22) Jan 17 '19 at 22:06
1

So the comment @GordonDavisson gave above got me thinking about permissions and with a little extra searching I ended up finding this answer to How can I delete Time Machine files using the commandline

I ended up doing the following

% du -sh geek-imac.sparsebundle
711G    geek-imac.sparsebundle

% hdiutil attach geek-imac.sparsebundle
/dev/disk3              GUID_partition_scheme           
/dev/disk3s1            EFI                             
/dev/disk3s2            Apple_HFS                       /Volumes/Time Machine Backups

% cd <to appropriate folder>

% sudo /System/Library/Extensions/TMSafetyNet.kext/Contents/Helpers/bypass rm -rf *.m4v

%  hdiutil detach disk3
"disk3" unmounted.
"disk3" ejected.

% hdiutil compact geek-imac.sparsebundle
Starting to compact…
Reclaiming free space…
............................................................................................................................................................................................................................................
Finishing compaction…
Reclaimed 172.2 GB out of 1.3 TB possible.

% du -sh geek-imac.sparsebundle
539G    geek-imac.sparsebundle

I had not heard of bypass before, but will keep it in my toolbox for future work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .