An APFS Bug in macOS High Sierra Can Cause Data Loss in Disk Images

There’s a bug in the APFS file system on macOS High Sierra that can cause data loss in disk images formatted in APFS. A blog post by Mike Bombich, creator of Carbon Copy Cloner, gives more details.

APFS Bug

Disk images are unique to macOS. They are files, but act like a hard drive. You mount the disk image like a hard drive, and you can store other files and folders within it. Mike found that a sparsebundle disk image he had formatted with APFS showed a lot of free space, even though the disk was full. He demonstrated it with a video:

https://youtu.be/k60NvrJnNOY

He then copied a file to the image, and it copied without errors. However, when the disk image was unmounted and remounted, the video file was corrupted. Mike discovered there were two bugs in macOS’s “diskimages-helper” service that caused this.

With the first APFS bug, the free space on an disk image isn’t updated when the free space on the physical host disk is shrunk, although it should. The second bug is the lack of error reports when these write requests don’t dynamically grow the disk image. This means that data is written into a “void.”

However, disk images with an extension of “.dmg” aren’t affected by this. The storage for these types of images are pre-allocated when they are created, so their storage space is guaranteed. These bugs affect sparse disk images, and they have an extension of “.sparseimage.”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.