How can you create a valid/reliable disk image of APFS drives?
Last year before Catalina was released, I tried to perform a disk image of my boot drive of Mojave (macOS 10.14) on a new computer before updating and customizing it. I have done this for years to preserve a certain state of macOS installation for future re-use. BUT this time with Mojave, I kept running into many errors. So how can this be done? Is this no longer allowed by Apple?
To be clear, looking for a solution using with Disk Image Utility only, not third party tools.
I FOUND THE SOLUTION to using Apple Disk Utility to create RELIABLE disk images of APFS drives. The ONLY path to make a viable re-usable disk image formatted as APFS in 3 simple steps is (though finding the solution was not simple to figure out nor straight-forward):
-
First create a blank image file formatted as APFS and Read/Write (requires pre-determining size of image file). IMPORTANT NOTE: The image (destination) cannot be stored on the same drive or partition (source) from which you are going to create the image.
-
use Restore from to clone to newly created image file (Highlight destination then click [Restore] button and select Restore From .
-
convert image file to Compressed format (Image > Convert).
ONLY THEN do you have a reliable APFS image, especially w/bootable macOS. I have done this repeatedly and it works fine. The important distinction with this solution is that it not only creates a valid disk image, the image can then be used to re-create a boot volume, which is after all, the point of this.
ANY other options/paths, are greyed out, yield "Resource busy" or "image is not APFS format" errors or produces image that is not reliable. Even using Apple Internet Recovery tools/boot was the same.
NOTE: you do NOT need to do ANY of this using Recovery tools. You can do this from a live boot of macOS drive. If you do not have a destination to store the image file other than the same internal drive, you can create a partition large enough to store the image file, using Disk Utility. And yes, you can partition macOS boot drive live.
CAVEAT: Tested only using Mojave 10.14.4 on 2019 27" i9 iMac w 40GB RAM and 512GB SSD (no T2 chip), so YMMV.
Apple needs to fix Disk Utility to work straightforward like it used to but with better support for APFS.
HTH.
BTW, I posted original answer in the open forum here: https://forums.macrumors.com/threads/mojave-and-hfs-it-can-be-done.2125194/page-2#post-27595211
In my search for an answer to the above question, I could not find the correct answer... several threads on this site and others give the WRONG answer, essentially, "it is not supported" or "it cannot be done"... This is the WRONG answer.
In the answer section I post the CORRECT answer, which I discovered through a lot of experimentation. This corrects the answers provided at each of the links below, which are all wrong:
Create a disk image for recovery
"Create disk image" disabled
How to Make Bootable APFS Volume From Disk Image (for this thread you need the equivalent terminal commands to do what is described above).
The info provide by @grg (in the first thread) is not correct. Even in the image provided it shows that you cannot create an "Image from SSD" because it is greyed out. Even booting into Recovery does not accomplish the desired results in that answer...