Repair Time Machine sparsebundle that will no longer mount I messed up my Time Machine backup in some way. I'm no longer able to mount the sparsebundle file as I get an error stating that there are no mountable filesystems.

I used the hdiutil command to attach the sparsebundle file:

hdiutil attach -nomount -readwrite flattop.sparsebundle


which resulted in the following /dev/ devices:

/dev/disk2              Apple_partition_scheme
/dev/disk2s1            Apple_partition_map
/dev/disk2s2            Apple_HFSX


Afterwards I ran the fsch_hfs command to check the main volume (/dev/disk2s2):

fsck_hfs -drf /dev/disk2s2


This resulted in a notice that the Time Machine Backups volume is corrupt and needed to be repaired:

Unable to open block device /dev/disk2s2: Permission deniedjournal_replay(/dev/disk2s2) returned 13
** /dev/rdisk2s2 (NO WRITE)
    Using cacheBlockSize=32K cacheTotalBlock=32768 cacheSize=1048576K.
   Executing fsck_hfs (version diskdev_cmds-540.1~34).
Non-empty journal:  start = 66310144, end = 94912512
   Journal need to be replayed but volume is read-only
** Checking Journaled HFS Plus volume.
** Detected a case-sensitive volume.
   The volume name is Time Machine Backups
** Checking extents overflow file.
   Unused node is not erased (node = 3568)
   Unused node is not erased (node = 3574)
   Unused node is not erased (node = 3575)
** Checking catalog file.
** The volume Time Machine Backups was found corrupt and needs to be repaired.
    volume type is pure HFS+ 
    primary MDB is at block 0 0x00 
    alternate MDB is at block 0 0x00 
    primary VHB is at block 2 0x02 
    alternate VHB is at block 2865568974 0xaacd1cce 
    sector size = 512 0x200 
    VolumeObject flags = 0x07 
    total sectors for volume = 2865568976 0xaacd1cd0 
    total sectors for embedded volume = 0 0x00 


As you can see there is also an error saying "Unable to open block device /dev/disk2s2: Permission deniedjournal_replay(/dev/disk2s2) returned 13".

I thought this might be due to not running the fsck_hfs command as a su, so I tried it with sudo but this had the same result.

My sparsebundle file is on a Synology DS408 NAS and has been running without a problem for about 2 years now :(

Anyone an idea how to take this further?

Kind regards,
Niels R.

UPDATE: As I suspected while writing this question I probably have a problem with read/write permissions. I now see the volume appearing in the Disk Utility and when I click on "Verify" I get the following output:

Verifying volume “Time Machine Backups”
Checking file systemJournal need to be replayed but volume is read-only
Checking Journaled HFS Plus volume.
Detected a case-sensitive volume.
Checking extents overflow file.
Unused node is not erased (node = 3568)
Checking catalog file.
Keys out of order
The volume Time Machine Backups was found corrupt and needs to be repaired.
Error: This disk needs to be repaired. Click Repair Disk.


Can I simply chmod the sparsebundle file to set the right permissions?
I have a write up on how to try and repair NAS-based sparsebundle errors on my blog.  In summary:


hdiutil attach -nomount -noverify -noautofsck /Volumes/{name of your disk}/{name of}.sparsebundle

You will then see something like

/dev/diskx Apple_partition_scheme
/dev/diskxs1 Apple_partition_map
/dev/diskxs2 Apple_HFSX


Where x is the disk id for the external disk. x might be 2, 3, 4 or
higher. You are interested in the one labeled Apple_HFSX or Apple_HFS. 
fsck_hfs -drfy /dev/diskxs2 using whatever relevant device was located in Step 1.

Hopefully, you will eventually see


  The Volume was repaired successfully

hdiutil detach /dev/diskxs2




However, since OS X 10.6.3, Time Machine will refuse to write to a destination volume that fails its verification.  Even if the process above succeeds in recovering the backup, you may still need to remove the black marks that Time Machine wrote when it failed verification.


Unlock the sparsebundle

chflags -R nouchg /Volumes/{name of your disk}/{name of}.sparsebundle

Move it back to its original location

mv /Volumes/{name of your disk}/{name of}_YYYY-MM-DD.sparsebundle /Volumes/{name of your disk}/{name of}.sparsebundle

At the top level directory of the sparsebundle, edit the file com.apple.TimeMachine.MachineID.plist.


Remove

&lt;key&gt;RecoveryBackupDeclinedDate&lt;/key&gt;
&lt;date&gt;{whatever-the-date}&lt;/date&gt;

Change

&lt;key&gt;VerificationState&lt;/key&gt;
&lt;integer&gt;2&lt;/integer&gt;


to

&lt;key&gt;VerificationState&lt;/key&gt;
&lt;integer&gt;0&lt;/integer&gt;