Despite the irresistible rise of the SSD, I know that many of you are still making Time Machine backups to rotating hard disks. Although in recent versions of macOS they’re now in APFS format, so should be less prone to the errors which plague HFS+ backups, you still want to check your backup storage. Yet, when you try that in Disk Utility, all you see are errors or you have wait an age while every snapshot is checked. And Disk Utility won’t just check the backup disk, but insists on repairing it whether you want it to or not.
When Glenn Fleishman @GlennF raised the question of checking APFS backup storage, we recognised multiple conflicts:
- Although hard disks have become more reliable, they’re still prone to disk errors, so deserve periodic checks of the file system.
- APFS isn’t an ideal file system for hard disks; although backup snapshots are read-only, so relatively stable, most are also badly fragmented, and can’t be defragmented.
- Checking dozens or even hundreds of backup snapshots stored on hard disks can take many hours.
- If you don’t check the snapshots, there’s little point in checking your backup storage, as all your backups are stored in snapshots.
- As snapshots are read-only, if they develop errors, it appears that they can’t be repaired anyway.
- If a backup snapshot develops an error, there’s no way to replace it, as snapshots can’t be copied from another volume.
And that’s before you even consider the tmutil verifychecksums
command, which has to be run on individual backups, and may not work for backup snapshots either.
To save you reading the detail below, if you just want my recommendation, here’s the procedure step by step:
- Turn automatic Time Machine (TM) backups off in the TM pane.
- In Disk Utility (or Terminal) obtain the device name of your TM backup volume. In this case, I’ll use
disk9s2
, which is the sort of name you’re looking for. - In Disk Utility (or Terminal) unmount the volume, by selecting it and clicking on the Unmount tool.
- Open Terminal and type the command
sudo fsck_apfs -n /dev/disk9s2
where you use the correct device name instead ofdisk9s2
. Then enter your admin user’s password at the prompt. - Watch as the backup volume and all its snapshots are checked.
- Once that has completed, decide whether the volume needs repair using First Aid.
- In Disk Utility (or Terminal) mount the volume again, by selecting it and clicking on the Mount tool.
- Turn automatic TM backups on again in the TM pane.
Note: if your backups are encrypted, the fsck_apfs command almost certainly won’t work. There are three different ways you can use instead, as detailed in the following more general article.
Details
When Disk Utility runs First Aid on an APFS volume, it uses the command fsck_apfs -yx
on that volume. That performs a full check on the volume, and automatically performs any repairs on it that the command offers. The x
option is not only undocumented in the command’s man page but it isn’t even listed in its usage info.
fsck_apfs
has other options to consider.
fsck_apfs -q
runs a quick check which typically returns:
** Checking the container superblock.
Checking the checkpoint with transaction ID 53369.
** Checking the object map.
** Checking volume /dev/rdisk9s2.
** Checking the APFS volume superblock.
The volume ThunderBay2 was formatted by diskmanagementd (1677.81.1) and last modified by apfs_kext (1933.41.2).
** QUICKCHECK ONLY; FILESYSTEM CLEAN
Although that’s useful, it hasn’t checked anything other than overall integrity of the volume, which excludes all the backup snapshots.
fsck_apfs -n -S
runs a full check, but doesn’t perform any repairs, and excludes all snapshots. That typically returns:
** Checking the container superblock.
Checking the checkpoint with transaction ID 53369.
** Checking the space manager.
** Checking the space manager free queue trees.
** Checking the object map.
** Checking volume /dev/rdisk9s2.
** Checking the APFS volume superblock.
The volume ThunderBay2 was formatted by diskmanagementd (1677.81.1) and last modified by apfs_kext (1933.41.2).
** Checking the object map.
** Checking the snapshot metadata tree.
** Checking the snapshot metadata.
** Checking the extent ref tree.
** Checking the fsroot tree.
** Verifying volume object map space.
** Verifying allocated space.
** The volume /dev/disk9s2 appears to be OK.
That’s more useful, but still doesn’t check our backups, as the command tells it not to. If you want to leave snapshots out, this is definitely the best command for your check.
fsck_apfs -n
runs a full check, including all the snapshots, but doesn’t perform any repairs. Typical output runs:
** Checking the container superblock.
Checking the checkpoint with transaction ID 53369.
** Checking the space manager.
** Checking the space manager free queue trees.
** Checking the object map.
** Checking volume /dev/rdisk9s2.
** Checking the APFS volume superblock.
The volume ThunderBay2 was formatted by diskmanagementd (1677.81.1) and last modified by apfs_kext (1933.41.2).
** Checking the object map.
** Checking the snapshot metadata tree.
** Checking the snapshot metadata.
** Checking snapshot 1 of 84 (com.apple.TimeMachine.2021-03-31-073108.backup)
[and so on to]
** Checking snapshot 84 of 84 (com.apple.TimeMachine.2021-11-17-082229.backup)
** Checking the extent ref tree.
** Checking the fsroot tree.
** Verifying volume object map space.
** Verifying allocated space.
** The volume /dev/disk9s2 appears to be OK.
If you do want to check the backup snapshots, that’s clearly the best command to use.
I’m open to better suggestions.