This is my current partition map:

$ diskutil   list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *121.3 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Hummingbird             100.5 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

$ sudo hdiutil pmap -complete -endoffsets -shims -uuids /dev/disk0

MEDIA: ""; Size 113 GB (236978176 x 512); Max Transfer Blocks 2048
SCHEME: 1 GPT, "GPT Partition Scheme" [16]
SECTION: 1 Type:'MAP'; Size 113 GB; Offset: 34 - 236978143, (236978109 x 512); Overhead 67; UUID: 0000146C-6D0C-0000-F108-0000266E0000

ID Type                 Offset       Size         End          Name                      (3)
-- -------------------- ------------ ------------ ------------ -------------------- --------
   Free                           34            6           39
 1 EFI                            40       409600       409639 EFI system partition 00005552-571C-0000-C278-0000F1770000
 2 Apple_HFS                  409640    196236456    196646095 Hummingbird          0000026E-6D8D-0000-6064-0000840F0000
 3 Apple_Boot              196646096      1269536    197915631 Recovery HD          2175E76A-2663-4D30-8EF6-21786653B4A3
   Free                    197915632     39062511    236978142

$ sudo gpt -vvvv show /dev/disk0
gpt show: /dev/disk0: mediasize=121332826112; sectorsize=512; blocks=236978176
gpt show: /dev/disk0: PMBR at sector 0
gpt show: /dev/disk0: Pri GPT at sector 1
gpt show: /dev/disk0: GPT partition: type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, start=40, size=409600
gpt show: /dev/disk0: GPT partition: type=48465300-0000-11AA-AA11-00306543ECAC, start=409640, size=196236456
gpt show: /dev/disk0: GPT partition: type=426F6F74-0000-11AA-AA11-00306543ECAC, start=196646096, size=1269536
gpt show: /dev/disk0: Sec GPT at sector 236978175
      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  196236456      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  196646096    1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  197915632   39062511
  236978143         32         Sec GPT table
  236978175          1         Sec GPT header

$ diskutil  resizevolume  /dev/disk0s2  limits
For device disk0s2 Hummingbird:
        Current size:  100.5 GB (100473065472 Bytes)
        Minimum size:  100.5 GB (100473065472 Bytes)
        Maximum size:  100.5 GB (100473065472 Bytes)

It's the result of previously having a Bootcamp partition, which I've removed using diskutil eraseVolume "Free Space" "Free Space" disk0s4 (after first backing it up as an image to external storage).

I would like to move disk0s3 to the end of the disk, i.e. offset 236978142-1269536 = 235708606 (or an appropriate approximation thereof for SSD alignment), so that s2 (my root partition) is free to resize.

How can I do so, ensuring that GPT is aware of it?


Answer to Posted Question

When you enter the diskutil command to resize your boot partition disk0s2, the recovery partition disk0s3 will automatically be moved. You do not want to move this recovery partition to the end of the disk using a separate command. In other words, you are trying to do the wrong thing.

See Merge partitions with Macintosh HD for the correct procedure.

Response to Comment: What if I want to leave some free space in the middle, e.g. for another partition later, but have the recovery partition at the end?

The recovery partition should always follow after the boot partition. For example I have Yosemite installed in partition disk0s5 and El Capitan in partition disk0s7. Both partitions are followed by their respective recovery partitions. Below is my current partitioning.

Sector size is 512 bytes.
Drive contains 1,953,525,168 sectors.
Drive contains 1,000,204,886,016 bytes (1.00 TB).

       start        size  index  contents
           0           1         MBR
           1           1         Pri GPT header
           2          32         Pri GPT table
          34           6
          40      409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
      409640        2008
      411648   394530816      2  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
   394942464   394530816      3  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
   789473280    97654784      4  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
   887128064      262144
   887390208   478769528      5  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  1366159736     1269536      6  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  1367429272   195995208
  1563424480   388568960      7  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  1951993440     1269544      8  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  1953262984      262144      9  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
  1953525128           7
  1953525135          32         Sec GPT table
  1953525167           1         Sec GPT header

I have 100 GB of free space between partitions disk0s6 and disk0s7. I could, for example, install Linux in this free space. (For the curious, partition disk0s9 is a second EFI partition which contains the rEFInd boot manager.)

To determine the limits for resizing your partition, use the following command.

diskutil  resizevolume  /dev/disk0s2  limits

When a partition is followed by a recovery partition, the previous command will display the correct minimum size and display the maximum size to be to the current size. The actual maximum size may be larger than this value. You will need to use the gpt command or some equivalent method to determine the free space the follows the recovery partition.

For example, to change your partition size to 110 GB, you would enter the following command.

diskutil  resizevolume  /dev/disk0s2  110G

To change your partition size to the maximum size of approximately 120 GB, enter the command

diskutil  resizevolume  /dev/disk0s2  R

You can enter the command man disktuil, for more information.

  • What if I want to leave some free space in the middle, e.g. for another partition later, but have the recovery partition at the end? – Sai May 30 '16 at 17:53
  • 1
    @Sai: I updated my answer. – David Anderson May 31 '16 at 1:32
  • Thanks for the detailed info. You say that recovery "should" always follow the main one it's associated with. Why? (I am used to bootloaders, e.g. GRUB, which when invoked will just let you choose whichever you want, and don't particularly care about ordering if you give a UUID or offset to identify the desired partition [or other craziness it can load].) – Sai May 31 '16 at 10:47
  • PS Updated OP w/ output of diskutil limits & list. – Sai May 31 '16 at 10:50
  • 1
    @Sai: I corrected my answer. The maximum size is actually approximately 120 GB. – David Anderson May 31 '16 at 19:34

You must log in to answer this question.

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