Ok, so it turns out this error -5344: MediaKit reports not enough space on device for requested operation
is caused by the fact that you are trying to expand a container backward into free space that exists before it on the partition list, even though Disk Utility (and by extension diskutil
) can only expand partitions forward into free space that comes after the container in the partition list. Another notable error is your attempt to resize the Physical Store partitions on which the Container disks are stored (disk0s2 and disk0s4), rather than the Container disks themselves (disk3, disk4, and disk5 in the below example).
With a bit of trial and error I was able to figure out how to effectively merge Containers 2 and 3 into one, with no data loss to Container 1. Note that this will require the deleting of the Mojave beta partition, so make sure you either have it backed up, or have an installer on hand.
UPDATE: There is a way to do this without having to reinstall the second OS. In macOS versions up to Sierra (I haven't tried it in newer) you could create directly bootable backups of your entire system with (adjusting for the disk names you gave in your question) sudo ditto -V -X --nocache /Volumes/Mojave\ beta/ /Volumes/Untitled/
NOTE: for backing up the currently booted system, subsitute /Volumes/Mojave\ beta/
with /
For posterity please make sure you have a macOS installer (USB or Recovery HD) on hand for each OS you have installed.
Please also remember that these disk lables are just the ones for my disk on my system, always double check the names are correct for yours when running these commands by comparing them with the output of diskutil apfs list
In order to replicate your situation the best I could, using Disk Utility I formatted a 4 GB flash drive as APFS. I then partitioned the disk two separate times, which resulted in three APFS Containers, and three virtual volumes, in the following order:
First Container
Container disk3 - 1.85G
Physical Store disk2s2
Volume disk3s1
Second Container
Container disk4 - 0.94G
Physical Store disk2s3
Volume disk4s1
Third Container
Container disk5 - 0.94G
Physical Store disk2s4
Volume disk5s1
I then opened a terminal, and deleted the Third Container with: diskutil apfs deleteContainer disk5
, which resulted in disk2s4 being converted into an HFS+ volume.
After this I deleted the partition disk2s4, and in so doing freed up the space necessary to expand the Second Container by running diskutil eraseVolume "Free Space" "" disk2s4
At this point the partition list looked like this:
First Container
Container disk3 - 1.85G
Physical Store disk2s2
Volume disk3s1
Second Container
Container disk4 - 0.94G
Physical Store disk2s3
Volume disk4s1
Free Space - 0.94G
Finally I was able to expand the Second Container to 1.85 GB with diskutil apfs resizeContainer disk4 1.85G
. The final result of this is two APFS Container disks of equal value on the flash drive:
First Container
Container disk3 - 1.85G
Physical Store disk2s2
Volume disk3s1
Second Container
Container disk4 - 1.85G
Physical Store disk2s3
Volume disk4s1
Besides adjusting the commands so that the disk labels match those on your own machine, the one notable substitution you should make is changing 1.85G to 100G in the final command. Beyond that this should be all you need to make the conversion requested.
Container
disks? If the former, in order to purge the extra partition you may try first unmounting theUntitled
partition, and formatting theContainer disk1
partition as HFS+, at which point you should be able to partition the entire disk and remove the second partition completely. As far as resizing issues go, I'm afraid I use an HDD based system, and haven't spent enough time on Mojave Beta to get acquainted with APFS's partitioning quirks.Macintosh HD
/Mojave beta
, then resizing theContainer disk0
andContainer disk2
. Seeing as being booted into either OS on the internal disk will stop you from unmounting its respective partition, which will in turn stop you from resizing its container partition, booting from an external disk may allow you to make the necessary modifications to the internal disk.sudo diskutil apfs resizeContainer disk0s2 400g jhfs+ disk0s4 75g
, but I keep gettingA problem occurred; undoing all changes Error: -5344: MediaKit reports not enough space on device for requested operation
when it gets to the end.