My drive is formated to hfs+ and it is not clean.

In example when I'm trying to mount the drive by mount -f -o rw, dmesg displays the error:

hfs: Filesystem was not cleanly unmounted, running fsck.hfsplus is recommended.
mounting read-only.

So when I'm trying to repair it via fsck.hfsplus (part of hfsprogs) it says:

$ fsck -dyf /media/sdd2
** /dev/sdd2
    Using cacheBlockSize=32K cacheTotalBlock=1024 cacheSize=32768K.
** Checking HFS Plus volume.
** Detected a case-sensitive catalog.
** Checking Extents Overflow file.
** Checking Catalog file.
   Invalid map node linkage
(4, 0)
** Volume check failed.
volume check failed with error 7 
    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 3906291630 0xe8d547ae 
    sector size = 512 0x200 
    VolumeObject flags = 0x07 
    total sectors for volume = 3906291632 0xe8d547b0 
    total sectors for embedded volume = 0 0x00 

Despite of using -y or -f, the drive is not being repaired.

Here is the explanation of that error according to this blog:

Once the B*-Tree has been checked, fsck moves on to checking the Allocation Map. fsck checks the header node as described above. Then it checks through each node making sure it identifies itself as a map node and has the proper number of records. If the node fails these checks fsck returns “Invalid Map Node.” Then fsck checks to make sure the node height is not 0 (“Invalid Node height”). Finally, if it has made it to the bottom of the tree and the mapSize,(which stores the total number of records in the tree and is decremented each time a node is processed) is not 0, fsck knows there are nodes that are orphaned and returns “Invalid map node linkage.”

However I don't know how to fix that error as it's not being corrected automatically and I can't mount the partition to be writable. Any ideas how to fix that error?

P.S. Disk Utility has similar problem.

up vote 4 down vote accepted

You should to try to rebuild the catalog file (B-tree) on the specified file system (which is HFS+) by specifying -r option for fsck, for example:

$ fsck.hfsplus -fryd /dev/sdd2

This option currently will only work if there is enough contiguous space on the specified file system for a new catalog file and if there is no damage to the leaf nodes in the existing catalog file (in other words, fsck is able to traverse each of the nodes in the requested btree successfully).

Of course, do the backup (whole image disk dump) before performing any disk operations, if you don't want to risk of corrupting any data further more.

See more by running man fsck.hfsplus.

If this won't help, try using some other tools to repair your disk, e.g.:

  • TestDisk by CGSecurity | Mac, Windows, Linux (apt-get install testdisk)
  • DiskWarrior by Alsoft (commercial) - bootable disk or Mac app
  • 1
    Rebuilding the B-tree did it for me. I was receiving errors like hfsplus: unable to find HFS+ superblock and fsck.hfsplus -f /dev/sdc2 would throw an error like "bad node structure". – aclave1 May 16 '17 at 0:26

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.