How should I delete a container to allow its disk space to be claimed by another container?

On my 2017 Macbook Air, running Big Sur, I created a new "container" to install Monterey to test it. So I have a dual-boot system with Big Sur and Monterey living on two separate containers (along with separate copies of all my user and other files). Here is the diskutil list ...

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *240.0 GB   disk0
   1:                        EFI ⁨EFI⁩                     209.7 MB   disk0s1
   2:                 Apple_APFS ⁨Container disk2⁩         119.9 GB   disk0s2
   3:                 Apple_APFS ⁨Container disk1⁩         119.9 GB   disk0s3

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +119.9 GB   disk1
                                 Physical Store disk0s3
   1:                APFS Volume ⁨for_monterey - Data⁩     60.7 GB    disk1s1
   2:                APFS Volume ⁨for_monterey⁩            15.7 GB    disk1s3
   3:              APFS Snapshot ⁨com.apple.os.update-...⁩ 15.7 GB    disk1s3s1
   4:                APFS Volume ⁨Preboot⁩                 274.5 MB   disk1s4
   5:                APFS Volume ⁨Recovery⁩                1.1 GB     disk1s5
   6:                APFS Volume ⁨VM⁩                      3.2 GB     disk1s6

/dev/disk2 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +119.9 GB   disk2
                                 Physical Store disk0s2
   1:                APFS Volume ⁨BigSurHD - Data⁩         64.8 GB    disk2s1
   2:                APFS Volume ⁨Preboot⁩                 317.5 MB   disk2s2
   3:                APFS Volume ⁨Recovery⁩                626.3 MB   disk2s3
   4:                APFS Volume ⁨VM⁩                      1.1 GB     disk2s4
   5:                APFS Volume ⁨BigSurHD⁩                15.3 GB    disk2s5


I'm happy with Monterey, so I want to delete Big Sur and make my entire disk available to Monterey.

Can I simply go to DiskUtility and delete the Big Sur container, thereby ending up with a single container filling my entire disk ? It appears not; if I click on "Partition" in the DiskUtility, while booted into Monterey, the '-' button is greyed out for BigSur.

So must I clone my Monterey container onto an external disk, wipe the internal disk, and restore the Monterey container back? I believe I can do this with the Disk Utility too, using disk images; but I'm unclear on the exact steps.


Solution 1:

If you are sure suppress Big Sur and replace it by Monterey, you can do that (I suppose you have a save TM or CCC of you Big Sur install) :

From Monterey you clone the Monterey install on the Big Sur Container :

sudo asr --source /dev/disk1s3s1 --target /dev/disk2 --erase

You will be asked to enter your password which is not displayed when you type it and then you will have to validate the deletion of the ex-Big Sur Container.

Then the copy will take about 5 or 10 minutes.

Then you boot on the new Monterey, with the Alt key and you choice the thirst "⁨for_monterey" item.

Your two install will have the same name and you verify that you are on the good Container (the first). The command :

diskutil list 

Give you this information.

The active container have a “APFS Snapshot ⁨com.apple.os.update-..” volume.

If ok you suppress the second (original) Monterey Container :

diskutil ap deletecontainer diskx tokill

then

diskutil erasevolume free space disk0s3

And you add the free space to your new Monterey install

diskutil ap resizecontainer disky 0b

Of course diskx and disky must be replaced by the real values given by the command :

diskutil list

If you have a doubt after the reboot on the new Monterey Volume, you give the results of the command :

diskutil list

And I will give you the appropriate commands.