Disk Utility fails with OSStatus error 22 during cloning/recovery operation

apfsdisk-utilityrecovery-hdupgrade

Background:

I need to upgrade the drive in my Macbook Pro. Following are some of its specs:

  • MacBook Pro (17-inch, Late 2011)
  • OS: High Sierra, v 10.13.6
  • HDD: 500 GB SSD, w/ Macintosh HD & BOOTCAMP partitions

The Problem:

I need to upgrade the SSD to 1TB. I can accomplish this by cloning the 500GB drive to the 1TB drive. I will use Disk Utility from the Recovery HD volume to do this since both source and destination volumes in the cloning process will need to be unmounted.

I did this previously when upgrading the original mechanical HDD to SSD, but it was HFS-to-HFS. I quickly reviewed this article to verify nothing had changed. Finding no warnings, cautions or surprises, I began the process:

  • boot with commandR to get into the Recovery HD volume
  • start Disk Utility
  • select Restore option
  • designate source (500GB) & destination (1TB) drives
  • Go!

This ran overnight (many hours). But instead of seeing a "Success" message this morning, I saw an error:

Inverting target volume...  
APFS inverter failed to invert the volume - invalid argument
The operation couldn't be completed. (OSStatus error 22.)
Operation failed...  

Research on this led me here. I initially concluded Apple had simply not upgraded the Recovery volume or the apps in it, but this proved not to be the case. Here's what I've found:

  • The upgrade to High Sierra converted the 'primary' volume to APFS, but left the Recovery volume as HFS.
  • The version of Disk Utility (DU) in the Recovery volume of my MBP is the same version as DU in my 'primary' High Sierra volume – it was apparently upgraded concurrently with the High Sierra upgrade.
  • Whatever the version of DU in the Recovery volume, the failure I experienced seems rather chronic.

The source disk is a Crucial SSD, a few years old & no known issues; the destination disk as also a Crucial SSD – about a week old. Nevertheless, I have now checked all volumes on both disks with First Aid in DU, and all are reported as "OK".

Based on all the above, I've concluded that my Recovery volume is unreliable and not fit for purpose.

I've found a 3rd party alternative solution, Carbon Copy Cloner. It has now successfully cloned the 500GB drive, and restored that to the new 1TB drive – I am "whole" again 🙂 My questions (at last) are:

  1. Can the Recovery HD volume be upgraded – perhaps by installing a later version of Disk Utility from Mojave or Catalina, or a 3rd party app such as CCC?

  2. Could the Recovery HD volume be converted from HFS to APFS and restored/installed on the internal SSD?

  3. Can a Recovery HD volume be created on a thumb drive which could be made bootable?

Best Answer

I came here because I was looking for solutions about the error you quote, but instead your actual questions at the end of your text are about something else. It would be nice if you'd change your question title accordingly.

To answer your questions about recovery partitions:

  1. If you install, even temporarily, a newer macOS, you should get a newer recovery partition along with it. I, for instance, have a separate 10.14.6 recovery system on one of my Macs (however, I wonder how that came to be, as there's also a Recovery APFS volume insider the container where the Mojave system resides, so why would there also be a HFS+ partition with one?). Be aware that if you install a newer system on your current system disk, it might convert your current system volume from HFS to APFS. To prevent that, install it to a separate partition (though even then I'm not sure that Apple won't simply convert all volumes on the disk to APFS), or best install it to an external disk.

  2. Converting it into APFS is not needed and inadvisible - it would not gain you anything. Basically, the Recovery system is just a small EFI-based loader that'll then load the BaseSystem image into a RAM disk and load the Recovery system from there.

  3. I have copied entire HFS+-formatted recovery partitions to external USB disks, so I assume you could as well copy them onto a USB stick, as long as you format it with a GUID partition scheme first. The copy operation may be tricky, though - ideally, Disk Utility should let you do that with its Restore command - but it turns that that the new Disk Utility won't even show Recovery partitions any more, so that's not an option. The old Disk Utility from pre-10.11 systems may be able to, still.

Here's what still works in my testing on Mojave with Terminal commands to copy a HFS+ formatted Recovery partition to an USB thumb drive (with GUID partition scheme):

asr --source /dev/diskVsW --target /dev/diskXsY --erase

Where diskVsW and diskXsY are the identifiers for the source and dest Recovery partitions that you'll find with diskutil list.

You could also use hdiutil to create an image file of another Mac's recovery partition and then later restore that with Disk Utility.

Also keep in mind that modern Macs can always load a recovery system from the internet, so there's no need to keep one around for them.