MacOS – How to resize partition after failed installation of Windows 10 via boot camp

bootcampdisk-utilitymacospartitionwindows

I have resized my main drive from 250gb to 200gb so I could have 50gb for Windows 10. Installation via boot camp failed and I was left with two partitions.
Somehow I deleted the smaller one (for Windows) and now I can not reclaim that space and resize my main partition to its original size of 250gb.

➜ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk1         192.0 GB   disk0s2
   3:       Microsoft Basic Data OSXRESERVED             8.0 GB     disk0s3

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +192.0 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            140.0 GB   disk1s1
   2:                APFS Volume Preboot                 45.8 MB    disk1s2
   3:                APFS Volume Recovery                1.0 GB     disk1s3
   4:                APFS Volume VM                      1.1 GB     disk1s4

DiskUtility:

DiskUtility not showing entire free space

I have tried resizing apfs container:

➜ diskutil apfs resizeContainer /dev/disk0s2 240g
Started APFS operation
Aligning grow delta to 48,000,000,000 bytes and targeting a new physical store size of 240,000,000,000 bytes
Determined the maximum size for the targeted physical store of this APFS Container to be 192,000,536,576 bytes
Error: -69771: The target disk is too small for this operation

Does anybody know how to reclaim that "invisible" free space and how to expand my main partition?

Any help is much appreciated.

Best Answer

Open a Terminal application window and enter the following commands.

sudo diskutil erasevolume free none disk0s3
sudo diskutil apfs resizecontainer disk0s2 0