Mojave: Unable to resize APFS container

On my macbook I had wanted to install Ubuntu so a while ago I had created a partition and installed it to half of my drive. I ended up not using the distro and wanted to reclaim the space. I tried following a few guides that suggested I run diskutil apfs resizeContainer disk0s2 0 after deleting the other partition. But upon running the command i get this error.

Error: -69519: The target disk is too small for this operation, or a gap is required in your partition map which is missing or too small, which is often caused by an attempt to grow a partition beyond the beginning of another partition or beyond the end of partition map usable space

How would I get arround this error to resize my container. enter image description here enter image description hereenter image description hereenter image description here


Disk Utility and diskutil (which Disk Utility uses behind the scenes) are refusing to increase the size of your APFS container because your recovery partition, "Recovery HD", appears to be in the way (though, for whatever reason, Disk Utility is not making this apparent in its diagrams). This probably became the case due to a direct upgrade from a pre-APFS version of macOS (i.e. Sierra or earlier) to Mojave; if you do a fresh install of Mojave, an APFS volume called "Recovery" is created inside the same APFS container used for your macOS installation, rather than a distinct HFS partition called "Recovery HD".

From the info you've provided, your 250 GB disk appears to be partitioned as follows:

+------------+---------------------------+-------------+-------------------------+
| EFI System | APFS container            | Recovery HD | Free Space              |
| Partition  |                           |             |                         |
| (210 MB)   | (125 GB)                  | (650 MB)    | (125 GB)                |
+------------+---------------------------+-------------+-------------------------+

But let's confirm this is the case: please share the output of sudo gpt -r show disk0 to see the GUID partition table proper.

If this is the case, you'll need to move the "Recovery HD" partition to the end of the disk, and then you should be able to increase the size of the APFS container which contains the "mint" APFS volume where macOS is installed. I am unsure if this could render your recovery partition unbootable, but it seems highly unlikely.