How to fix overallocation warnings
Several entries in this forum mention the overallocation warning that we can get when we use Disk Utility's first aid on an APFS container. Most posts are quite old and I have not seen a solution, so I tried to get one myself. Note that all steps were carefully performed with user accounts with admin rights.
This is what I did with my Mac running macOS Mojave
1) Create a bootable clone on an external drive, I used Carbon Copy Cloner and a Samsung T5.
2) Boot from the clone (press and hold the option key before power-up to get the boot menu)
3) Run DU first aid on the internal APFS container -> expand detail view
4) Scroll detail view up to find the path and name of the drive. In my case, it was /dev/disk0s2
5) Open Terminal
6) Enter sudo fsck_apfs -y -o /dev/disk0s2
The command will check all volumes of the container and then fix the overallocation
at the end of the procedure:
...
warning: Overallocation Detected on Main device: (187743823+1) bitmap address (16a44)
Fix overallocation (187743823+1) bitmap address (16a44)? YES
warning: Overallocation Detected on Main device: (187743825+1) bitmap address (16a44)
Fix overallocation (187743825+1) bitmap address (16a44)? YES
warning: Overallocation Detected on Main device: (192544935+1) bitmap address (13b69)
Fix overallocation (192544935+1) bitmap address (13b69)? YES
warning: Overallocation Detected on Main device: (201471821+1) bitmap address (13ca7)
Fix overallocation (201471821+1) bitmap address (13ca7)? YES
** The volume /dev/disk0s2 appears to be OK.
Wait until you get the prompt again, quit terminal and reboot your Mac from the internal drive.
If you now run DU first aid on the container, the overallocation warnings should be gone.
DISCLAIMER:
Using the Terminal requires a certain amount of care. Be sure to use the correct drive name as reported by DU. If anything goes wrong, you can run and restore your Mac from the clone.
iMac 27″, macOS 10.14