Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to solve "APFS inverter failed to invert the volume" error
After cloning APFS drives using Disk Utility it usually ends with a volume containing ContainerToInvert file with the size of a cloned partition.
Don't be afraid, using the following steps you can mount this file as APFS container and get all partitions.
1. Requirements
We need FUSE and xmount installed
2. Terminal
Open Terminal app and type the following:
$ sudo mkdir /Volumes/apfs_image/
$ sudo mkdir /Volumes/apfs_mounted/
$ sudo xmount --in raw <path to ContainerToInvert file> --out dmg /Volumes/apfs_image/
$ hdiutil attach -nomount /Volumes/apfs_image/ContainerToInvert.dmg
$ diskutil ap list
## this is optional step, I don't need it
$ diskutil ap unlockVolume <Disk GUID> -nomount
$ sudo mount_apfs -o rdonly,noexec,noowners /dev/disk# /Volumes/apfs_mounted/
After that, you will have the original partition mounted to your system.
References and Thank You’s
https://www.mac4n6.com/blog/2017/11/26/mount-all-the-things-mounting-apfs-and-4k-disk-images-on-macos-1013
@JacobSyndeo

This comment has been minimized.

Copy link

JacobSyndeo commented Aug 3, 2018

Fantastic work, thank you so much for this!
I've kept a 40 GB ContainerToInvert file on my disk for months now because I didn't know quite what it represented, and opening it with a hex editor revealed strings that matched the contents of several files on my drive. My worst-case fear of deleting ContainerToInvert was that it might somehow be some important part of APFS, and deleting it would either delete the files I saw in the hex editor or corrupt my drive (likely both).
But now I can browse it as a DMG, copying off whatever I need from it, and then safely delete it. Thanks so much again!!

@mehrdada

This comment has been minimized.

Copy link

mehrdada commented Nov 3, 2018

hdiutil attach -imagekey diskimage-class=CRawDiskImage ContainerToInvert -nomount

Should work without need for xmount and is simpler

@davidq1

This comment has been minimized.

Copy link

davidq1 commented Jul 13, 2019

I've been using the code above, still the files I found in my ContainerToInvert are corrupt or at least, I can not open them. mehrdata's way did not work for me either.. still the files seem to be corrupt :-/
any ideas?

@dmaksimov

This comment has been minimized.

Copy link

dmaksimov commented Sep 19, 2019

Super helpful! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.