Disk Utility fails on fsck_apfs: "disk is mounted"

I have an external SSD hard drive connected to my iMac via USB. I accidentally disconnected it while it was mounted, which caused a warning.

So I thought it would be prudent to run Disk Utility on the drive. When I do, fsck_apfs unmounts the disk, then complains that the disk is mounted and aborts:

Repairing file system.
Volume was successfully unmounted.
Performing fsck_apfs -y -x /dev/rdisk4s2
error: container /dev/rdisk4 is mounted.
File system check exit code is 65.
File system verify or repair failed. : (-69845)

And this is the top level message: "First Aid process has failed. If possible back up the data on this volume. Click Done to continue."

Any suggestions?


Solution 1:

Exact same thing happened to my backup disk, exact same message from Disk Utility.

Erasing and reformatting in APFS would generate the same error. Erased and reformatted in FAT then reformatted back to APFS and the First Aid error went away.

If, following the first Time Machine backup, it doesn't appear in Finder, restart the computer in Safe Mode and perform initial Time Machine backup. Confirm it shows up in Finder then shut down and start back up normally, Time Machine will then perform normally for subsequent backups.