Bundled disk checking and repair tools have something of a chequered history. Although they’ve been reasonably useful and reliable for much of the history of the Mac Extended or HFS+ file system, third-party tools have often outperformed Apple’s. Many Mac users have successfully recovered damaged disks which Disk Utility or
fsck have declared were unrepairable, which tools like Drive Genius and DiskWarrior have been able to repair.
This has changed with the arrival of Apple File System, APFS, largely because Apple has still failed to provide sufficiently detailed documentation to enable third parties to develop their own utilities to maintain or repair APFS volumes. As a result, several vendors have announced their intended support for APFS, but as far as I am aware at present, only limited functions are available in third party products at present. Apple’s tools remain the only serious options for APFS.
The sole exception is for volume recovery, a feature not offered in Disk Utility or
fsck. There is now at least one third party utility which can attempt to recover the contents of APFS volumes, as I describe below.
Check and repair
When you run either the command tool
fsck or the First Aid action in Disk Utility on an APFS volume, they simply call on the tool
fsck_apfs to perform the work. The only advantage in using
fsck or calling
fsck_apfs direct is in the other options available. In most circumstances, it is therefore simpler and just as effective to use Disk Utility to check and repair APFS volumes, as it handles their unmounting, calls
fsck_apfs, then remounts them without your having to call any additional actions or commands.
First Aid runs
fsck_apfs -y -x rdiskname
where rdiskname is something like /dev/rdisk3s1. The -y option ensures that
fsck_apfs performs all the repairs which it thinks it can, and the -x option returns its output in XML format, which is then displayed in the dropdown in Disk Utility, so that you can see the results of the test and repair.
Other options which are available in
fsck_apfs and might warrant calling it directly from the command line include:
- perform just a quick check to see if the superblock and checkpoint superblock are valid, -q
- verify only and don’t repair, -n
- skip iteration of snapshots, -S.
You can see the full list of options available with the command
as the man page may not be as accurate as its usage information.
Booting for repair
Whether you decide to do it the easy way using Disk Utility or run
fsck_apfs at the command line, the volume to be checked and repaired must normally be unmounted beforehand, something which Disk Utility handles for you. This is currently best accomplished by restarting in Recovery Mode, thus booting from the Recovery Volume, or an external bootable disk and performing the check and repair from there.
Using an external bootable disk has particular advantages here, because the Recovery Volume is within the same APFS container and partition map as the normal boot volume, which you probably also want to check and repair. Unfortunately, under standard Secure Boot settings, Macs equipped with a T2 chip can’t be booted from an external disk. In those circumstances, consider performing the repair with the Mac in Target Disk mode, from another Mac running the same version of macOS to ensure it has the same version of APFS too.
There’s now at least one product available which attempts to recover the contents of damaged or deleted APFS volumes. Stellar Data Recovery Professional for Mac performs a surface scan of APFS, HFS+ and other format disks and attempts to reconstruct their contents. Stellar is mainly priced on an annual subscription basis, currently around £/$/€ 59.99 per year, although there is a lifetime licence available for about £/$/€ 75. Higher prices are charged for options to repair videos and still images.
My own testing of Stellar confirms that it does a good job of recovering the contents of APFS volumes which have been deleted by putting them in the Trash and emptying. It achieves this using a painfully slow surface scan of the disk to be recovered, which is likely to take several hours at least on a disk of more than around 250 GB. It then uses heuristics to reassemble individual files, and basic knowledge of APFS file system metadata to reconstruct those files within their folder hierarchy. At present, it seems unable to distinguish between the contents of different APFS volumes within the same container, though, indicating that it is still evolving.
If you want to try recovering an APFS volume, Stellar Data Recovery appears to be the only capable product at present. However, using it reminded me of the many hours I spent in the distant past attempting similar tasks with lost HFS+ volumes in Classic Mac OS. We need more advanced tools which make better use of recovered file system metadata.
- For regular check and repair of APFS volumes, use the First Aid feature in Disk Utility.
- If possible, do this when booted from a different disk from the one you’re repairing.
- If that’s not possible/convenient, do this when booted in Recovery Mode.
- For T2 Macs consider putting them in Target Disk mode if Recovery Mode isn’t likely to be sufficient.
- Consider using
fsck_apfsfor more advanced and non-standard check and repair.
- To recover lost volume contents, consider Stellar Data Recovery.
- Apple needs to encourage and facilitate the development of more and better third party tools as a matter of urgency. APFS was released over two years ago, but still has few and limited third party tools.
Thanks to Michael for pointing out that my previous list of options for fsck_apfs was incorrect. That shown above has been corrected now. My apologies for this error.