Not able to get a partition that fills SSD

Solution 1:

Your new 512 GB disk has about 260 GB of unallocated disk space (starting at block 409640 and ending at block 511933959).

The on-board OS X tools don't allow you to move the beginning of a partition (the second partition starting at block 511933960) to smaller block numbers (like 409640).

My advice: create a new partition in the unallocated disk space. Clone the content of your current main volume to the new one. Then remove the current main volume and expand the new main volume. Additionally you should change the wrong type of your Recovery HD (i=3).

Preparation:

  • Attach a backup drive and backup your drive.
  • Detach the backup drive
  • Restart to Internet Recovery Mode by pressing alt cmd R at startup. Booting to Recovery Mode is not conducive because the Recovery HD will be removed in one of the steps below. And you can't remove a partition used as a boot volume.

    The prerequisites are the latest firmware update installed, either ethernet or WLAN (WPA/WPA2) and a router with DHCP activated.
    On a 50 Mbps-line it takes about 4 min (presenting a small animated globe) to boot into a recovery netboot image which usually is loaded from an Apple/Akamai server.

    I recommend ethernet because it's more reliable. If you are restricted to WIFI and the boot process fails, just restart your Mac until you succeed booting.

    Alternatively you may start from a bootable installer thumb drive (preferably Yosemite or El Capitan) or a thumb drive containing a full system (preferably Yosemite or El Capitan). If you boot to a full system and login as admin you have to prepend sudo to execute special commands like gpt ...!

Modify the GUID partition table

Not to get confused with the index number and the relative on-disk position of a partition:

AFAIK the default gpt settings allow 128 partition entries in the partition table. The index i of those entries runs from 1 to 128. You may use any free index number to add a new partition. The on-disk position of a partition is independent of the index number. Example: You can add the first partition (block 2-1000) with i=43, the second (block 1001-2000) with i=42 and the last one (block 2001-3000) with i=2. To remove the entry of the second partition you mustn't use i=2 (the on-disk position) but i=42!

  • Enter diskutil list and gpt -r show /dev/diskX (with diskX: the disk identifier of your internal disk (probably disk0)) to get an overview. In the commands below I assume the disk identifier is disk0.
  • Now modify the type of the Recovery HD:

    diskutil umountDisk /dev/disk0
    gpt remove -i 3 /dev/disk0
    diskutil umountDisk /dev/disk0
    gpt add -b 998945640 -i 3 -s 1269536 -t 426F6F74-0000-11AA-AA11-00306543ECAC /dev/disk0
    
  • Modify you main partition:

    diskutil umountDisk /dev/disk0
    gpt remove -i 2 /dev/disk0
    diskutil umountDisk /dev/disk0
    gpt add -b 511933960 -i 4 -s 487011680 -t 48465300-0000-11AA-AA11-00306543ECAC /dev/disk0
    
  • Add a new partition in the unallocated disk space:

    diskutil umountDisk /dev/disk0
    gpt add -b 409640 -i 2 -s 511524320 -t 48465300-0000-11AA-AA11-00306543ECAC /dev/disk0
    
  • Check if everything is fine:

    gpt -r show /dev/disk0
    

    Your partition table should finally look like this:

         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   511524320      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
     511933960   487011680      4  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
     998945640     1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
    1000215176           7
    1000215183          32         Sec GPT table
    1000215215           1         Sec GPT header
    
  • To quit Terminal enter:

    exit
    

    and quit Terminal

  • Format your new partition and clone your old main volume to the new volume:

    Open Disk Utility and erase/format the new partition (261.9 GB) to HFS+ Journaled. Give it a different volume name like Cantaloup2. The old main volume Cantaloup has the size 249.3 GB! Restore your old main volume to the empty new one.

  • Boot to your new main volume Cantaloup2.
  • If everything is working, remove your old main volume Cantaloup and expand Cantaloup2 to the full size.
  • Rename Cantaloup2 to Cantaloup.