Deleted Partitions and Wasted Storage

disk-utilitydisk-volumediskutilpartitionstorage

After doing diskutil list:

/dev/disk0 (internal):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                         500.3 GB   disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            140.0 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

and sudo gpt -r show disk0:

    start       size  index  contents
        0          1         PMBR
        1          1         Pri GPT header
        2          4         Pri GPT table
        6      76800      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
    76806   34169245      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
 34246051     158692      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
 34404743   87733384
122138127          4         Sec GPT table
122138131          1         Sec GPT header

I deleted some partitions I was using for a dual boot with Ubuntu using gdisk, but now Disk Utility nor diskutil will show empty space from deleting the volumes. Although my GUID_partition_scheme shows I have 500 gigs on the disk, the space is just gone and no longer able to be expanded to the "Macintosh HD" partition. I tried rebooting but nothing seems to work. Any ideas?

Best Answer

Under these circumstances - only one main volume - the proper command to expand it to its full size is:

diskutil resizeVolume /dev/disk0s2 R

This command will not work if your main volume is part of a CoreStorage Volume Group.