Extend main APFS partition fails with "target disk is too small for this operation"

/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         125.7 GB   disk0s2
   3:                  Apple_HFS Storage                 100.0 GB   disk0s3

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

I checked the different similar questions and tried the suggested solutions but in vain. Disk utility doesn't help at all.

I tried running this command from the terminal as suggested.

sudo diskutil apfs resizeContainer disk0s2 0

Error: -69771: The target disk is too small for this operation

I have more than 25 G of free space:

https://imgur.com/8o9RBvo


Solution 1:

The free space resides after disk0s3. The command you issued can not reclaim the free space back into disk0s2, because there little or no free space between disk0s2 and disk0s3. To reclaim approximately 25 GB of free space back to disk0s2, you would need to execute the following procedure.

  1. Remove the files from disk0s3.
  2. Delete disk disk0s3. You can use the command given below.

    sudo diskutil  eraseVolume free none disk0s3
    
  3. Add the approximately 125 GB of free space to disk0s2. You can use the command given below.

     sudo diskutil apfs resizeContainer disk0s2 0
    

Basically, it come down to this. If the files on disk0s3 are important, then you are going to need an external drive to temporarily store them. Once all the space has been returned to disk0s2, you can either create a new disk0s3 or create another APFS volume on disk0s2. Finally, restore the files from the external drive.