2

I wanted to merge 2 partitions disk0s2(unused space) and disk0s4(OS volume)

My disk looked like this:

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Untitled                500.6 GB   disk0s2
   3:                 Apple_APFS Container disk2         199.3 GB   disk0s4
   4:       Microsoft Basic Data BOOTCAMP                300.0 GB   disk0s5

Somewhere here I found a solution so I ran the command

sudo diskutil erasevolume "Free Space" %noformat% /dev/disk0s2

But then the next command

sudo diskutil apfs resizeContainer disk0s4 0

Gave 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

So now it looks like this:

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk2         199.3 GB   disk0s4
   3:       Microsoft Basic Data BOOTCAMP                300.0 GB   disk0s5

gpt show disk0

       start        size  index  contents
           0           1         PMBR
           1           1         Pri GPT header
           2          32         Pri GPT table
          34           6         
          40      409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
      409640   977979728         
   978389368   389234312      2  GPT part - 7C3457EF-0000-11AA-AA11-00306543ECAC
  1367623680   585901455      3  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
  1953525135          32         Sec GPT table
  1953525167           1         Sec GPT header

enter image description here

The best would be if I could make the main volume to the full space available, but if it's too difficult it would be enough to have that 500Gb as a separate volume as it was.

  • Firstly, welcome to Ask Different! :) I hope you come to find this site has a lot to offer! In case you haven't already, it's worth taking the time to read the tour. All the best! – Monomeeth Mar 5 at 21:44
3

Your free space is before the container, not after it. In order to expand it, you need free physical space after the container. You could try using a live CD (such as GNU Parted) to physically relocate the blocks of the APFS container to start at 409640, but this is perilous and should not be done without a backup.

  • Do you know for sure if GNU Parted handles moving APFS partitions? – David Anderson Mar 5 at 22:04
  • Since it's just physically moving the blocks around on disk, the filesystem in use isn't relevant. – parzival Mar 5 at 22:06
  • I agree with you. Now you just have to convince the authors of GNU Parted that that should be true. – David Anderson Mar 5 at 22:09
  • Oh man, they block it? That's bogus. Maybe it's time to do a custom build? Surely there are other free tools that will do the job, that's just the first one that popped up in my mind. – parzival Mar 5 at 22:26
  • Hold on. I am checking. To be sure, are you referring to GNU Parted or the GNOME Partition Editor? GNU Parted seems to only have a command-line interface, while the GNOME Partition Editor has a graphical interface. – David Anderson Mar 5 at 22:36

You must log in to answer this question.

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