How to fix the partition table after messing it up trying to install Linux Mint

disk-utilitypartitionunix

I tried to install Linux Mint alongside my working OS X Yosemite. I have a Macbook Air released mid 2013 with a 128gb SSD and 4gb of memory.

Well to achieve my aim I first added a partition using Disk Utility. To do so I simply took 30gb away from my "Macintosh HD" partition and left it as "Free Space".

Somehow the installation of Linux Mint from an USB drive failed and I wanted to get back my old partition table. Trying to do so something went wrong and I had to use Internet System Recovering to get a fresh copy of OS X 10.8.5, which I´m running now.

The problem is: when I call from the terminal : diskutil list
I get:

enter image description here

The Disk Utility App shows:
disk utility

So maybe you already guess my question: where are my missing 30gb of ssd space gone?
When I run Disk Utility, I only can make the Macintosh HD partition smaller. There is no possibility to erase disk0s5 partition, since: "MediaKit reports no such partition".

I have all my data stored in an external drive, so there is no measure I have to be afraid of in terms of loosing stuff… In fact I already "lost" the data I had on my computer.

I would really appreciate your help!


Update 1:

After executing the command

sudo gpt -r show /dev/disk0 

I get the following:

      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  173751112      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  174160752    1269544      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  175430296    1269536      4  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  176699832   56370760         
  233070592    3905536      5  GPT part - 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F
  236976128       2015         
  236978143         32         Sec GPT table
  236978175          1         Sec GPT header

I have to add: my goal is to assign the whole space to my Macintosh HD partition again…
Thanks

Best Answer

You first have to remove the swap partition and the visible Recovery HD with gpt and then you will be able to resize your Macintosh HD with Disk Utility.

Boot to Internet Recovery Mode by pushing altcmdR while booting.

Then open Terminal.app and enter (assuming disk0 is your main disk):

gpt -r show /dev/disk0 

Unmount your main disk with:

diskutil umountDisk disk0

First remove the Linux swap partition with:

gpt remove -i 5 disk0

(which means: remove the partition with the index number 5 on disk0).

and then the Recovery HD with the GUID 48465300-0000-11AA-AA11-00306543ECAC:

gpt remove -i 4 disk0

The Recovery HD with the GUID 426F6F74-0000-11AA-AA11-00306543ECAC is the proper one. Don't delete this one.

Finally remount disk0, quit Terminal, open Disk Utility, verify/repair your main volume "Macintosh HD" and finally expand it to the full size of your disk with the slider.

Related Question