13

I used to have a bootcamp partition but somehow while attempting to remove it its changed into a container disk. (don't know how this happened, I didn't explicitly create a container).

enter image description here

enter image description here

diskutil list:

/dev/disk0 (internal):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                         500.3 GB   disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                 Apple_APFS Container disk1         402.0 GB   disk0s2
   3:                 Apple_APFS Container disk2         97.8 GB    disk0s3
   4:                 Apple_Boot Boot OS X               134.2 MB   disk0s4

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +402.0 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            336.1 GB   disk1s1
   2:                APFS Volume Preboot                 23.2 MB    disk1s2
   3:                APFS Volume Recovery                515.0 MB   disk1s3
   4:                APFS Volume VM                      2.1 GB     disk1s4

/dev/disk2 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +97.8 GB    disk2
                                 Physical Store disk0s3

How can I delete this and merge its space back into the main drive?

0

2 Answers 2

18

Here, I assume the macOS volume that you boot to is Macintosh HD.

The commands below should remove the extra partitions and return the free space back to macOS.

 diskutil erasevolume free none disk0s4 
 diskutil apfs deletecontainer disk0s3 Untitled
 diskutil erasevolume free none disk0s3
 diskutil apfs resizecontainer disk0s2 0

If you are using Big Sur or newer, then you can just enter the commands given below.

 diskutil erasevolume free none disk0s4 
 diskutil apfs deletecontainer disk0s3
 diskutil apfs resizecontainer disk0s2 0
0
2

If you are looking for a non-command line version, there is also a way to do it from the native Disk Utility app.

  1. Open Disk Utility.
  2. Select the partition in the lefthand menu.
  3. Right click --> "Erase" (it will now rename to Container disk#)
  4. In the top righthand menu, press "Partition"
  5. Select the desired partition in the pie chart
  6. Press the "-" (minus) option directly under the Pie chart
  7. Wait for confirmation message (APPLE SSD AP0512M Media has been cleaned)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .