10

TL;DR

Asked the same question on Apple communities, nothing useful. Find the post here: https://discussions.apple.com/thread/8123614

bash-3.2# fsck_apfs -d -l /dev/disk5
fletcher64_init:58: Selecting AVX2 implementation of fletcher64
** Checking volume.
** Checking the container superblock.
** Checking the EFI jumpstart record.
** Checking the space manager.
** Checking the object map.
** Checking the APFS volume superblock.
warning: apfs_sb at apfs_fs_index (0): apfs_features has unrecognized features (2)
** Checking the object map.
** Checking the fsroot tree.
error: btn: key (2) compare error: 22
   fsroot tree is invalid.
** The volume /dev/disk5 could not be verified completely.

Hardware iMac (27-inch, Late 2013), 256GB stock SSD, nothing special, nothing fancy.

Standard issue hardware and I am certain that this hardware is flawless- since I run Linux/Freebsd on it.

Drive is a default single partitioned GPT for fresh install of High Sierra. I simply erased the whole drive, set a new GPT scheme, formatted it as HFS+ and started the installer from USB. This went ok, but after a few days I checked the Volume after power outage and found that I can't repair it anymore...

Disk Utility.app says the same what fsck does. Disk Utility is basically executing fsck in the background anyways, if you think it's not then start Disk Utility directly through Terminal and you will see it in stdout.

I couldn't find any useful documentation, just some marketing flavoured mambo-jumbo without any technical depth.

I installed the 10.13.1 Public Beta release with hopes that maybe it will recognize the unrecognized features, now it says more or less the same and still can't repair the volume - although it does not complain about unrecognized features.

I read somewhere that APFS is close related to ZFS, so maybe one can work with ZFS tools or other software that explicitly is designed to repair APFS similar to a back story here: http://dtrace.org/blogs/ahl/2016/06/15/apple_and_zfs/

Sub-topics

  • Is there a way to opt-out of APFS on SSD?
  • Is there a way to convert back to HFS+

During installation the installer didn't asked about conversion (or maybe I missed it) and now im stuck with a drive I can't use.


Update II: After reading a bit about ZFS and then references from Wikipedia entry about APFS (correct me if I am wrong) APFS implementation should take care off any faults on it's own, and, theoretically there is no need for a fsck command. Well, thinking of it, I never had to fsck a BTRFS volume either, if there were some issues there were scrubbed at boot time, guess this is how APFS is supposed to work as well - since fault tolerance is one of it's core features.

More technical details by reverse engineering APFS are here

Update III (07.01.2018)

After some weeks of APFs testing on native Apple and non-Apple hardware by doing a lot of common and some not so-common testing - I recommend to stay away from it until the Linux kernel is able to mount an APFS volume in R/W mode. From my experience one can expect to have a really bad day if your APFS based storage crashes for some reason and won't be able to self-heal. In most cases it does the job and can repair itself - however in 8 weeks I landed in more then 5 cases where it couldn't- despite no hardware failure. I was not able to repair/reuse the volume without reformatting therefore I'm not using APFS until it's well documented and mountable in Linux in R/W mode for anything else then system files.

SSD vs. non-SSD If you are running APFS on non-SSD: it will be slower then HFS. Period. APFS is (currently) only reasonable on internal SSD drives and on can be on hybrid drives (although Apple installer won't agree). Magnetic hard drives don't benefit from APFS in any way. External SSD drive performance is not really comparable since the amount data you can squeeze through USB-C is limited and HFS+ wont't be a bottleneck.

  • What is the memory configuration for this computer? Please be as specific as possible - what are the exact specifications for RAM in each slot, and are any of these non-Apple RAM? – Greg Glockner Jan 2 '18 at 16:13
  • 1
    I have 3 machines, each of them has the same issue with the fs, I transplanted the volume into usb and even dd'ed it to a different drive, all the same I wasn't able to get it repaired and clean. – PJJ Jan 7 '18 at 19:25
  • I have had no luck with repairing a corrupted APFS volume. I had to restore from backup. – Greg Glockner Jan 9 '18 at 8:55
  • meanwhile there seems to be some open source reverse engineered apfs driver c.f.: github.com/sgan81/apfs-fuse stumbled upon this and your story since I am having this somewhat similar issue apple.stackexchange.com/questions/323883/… – Rene Pickhardt Apr 28 '18 at 19:19
  • some open source software to keep eye on python recovery github.com/cugu/afro / apfs hex editor github.com/ydkhatri/APFS_010 – johndpope Jul 24 '18 at 1:35
4

Same advice as the Apple forums. Backup and reformat your system.

Apple has not released an APFS specification or code yet. As you have found, only very rough reverse engineering has been done. Trying to interpret what key 2 miscompare in the fsroot tree is pure speculation at this point.

There is no way to convert back to HFS+. There is an unofficial way to opt out though.

There is no need for a fsck command means that the FS will try to fix anything wrong on-the-fly, online. No filesystem can be immune from all potential damage or implementation bugs. If something can't be fixed by fsck offline, then there really is no chance to have it fixed online.

However, one potential scenario is a bug with fsck and not the system code, but again that's pure speculation without being able to understand what's wrong. It's your choice, but a reformat is the safest point.

  • I don't want to do this every few days - that's not an long term option. – PJJ Oct 21 '17 at 10:21
  • It is possible but not likely you have run across a bug. If you reformat and reinstall and the error recurs, I would look at a possible hardware error as being as (and possibly more) likely then a bug in APFS. – Steve Chambers Jan 5 '18 at 0:21
  • Might or might not - the problem is there is no documentation, no sources, no nothing. One can discover fsck_apf flags by searching into the binary - therefore I advise to stay away from APFS until the day when linux kernel can mount APFS volumes in r/w mode. – PJJ Jan 7 '18 at 19:15
2

Try checking your RAM.

I had a similar issue with 10.13 (High Sierra) on a 2017 iMac (18,3) with a factory SSD and 3rd party RAM. I got repeated freezes, and Disk Utility First Aid reported errors like "Object map is invalid" and concludes "File system verify or repair failed". Each time, I would reformat the SSD and reinstall macOS and software, but the problem would return after a few days. It passed Apple Diagnostics, and my local Apple Store was unable to detect any hardware problems (after I removed the 3rd party RAM). I have had no problems on multiple other computers, including 2 other iMacs, a MacBook and several macOS virtual machines.

What fixed it for me was to match RAM by bank, i.e. Bank 0 (DIMM 0/1) contains a matched pair of Apple RAM, and Bank 1 (DIMM 0/1) contains a matched pair of 3rd party RAM.

Update 2018-01-06: Just got another failure after 1 week. (This is the trouble with random failures). I have temporarily removed the 3rd party RAM while I do more testing.

Update 2018-01-22: After 10 days with new RAM, the problem has not occurred. I believe my problem was caused by bad RAM. (Maybe APFS uses RAM as a cache?).

  • Hi Greg, I more/less rolled back to HFS - from my personal experience I strongly advise to stay away from APFS until Apple releases either the sources / proper documentation and there is 3rd party implementation around. In short - don't touch APFS until the day linux kernel can mount it :) – PJJ Jan 7 '18 at 19:14
  • Been using it since day 1 official with no problems. I think APFS is not the problem here. Bad hardware might be instead. – Paul-Sebastian Manole Sep 17 '18 at 10:59
0

I was able to recover files after I created a disk image from the corrupted APFS partition and it can be mounted.

You must log in to answer this question.

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