MacBook does not mount, does not boot, does not read drive

When i press alt on my MacBook during startup, it only shows a disk that i used to have Windows installed (which is now empty). I erased that disk when i was last logged in on OS X. Then i tried to delete this partition and make the disk again as it was when i bought it 128GB.

There was an error. I thought that restart would be a good idea and that's what i did. Then what I wrote on first line happened. I just want some important files back; or reinstall OS X but keep old files.

Here are some photos I took. Recovery HD and Windows disks are empty, but I don't care about them.

disk0s2 is the disk i want to take files, it looks encrypted :(

enter image description here

Here is the result of sudo gpt -r show /dev/disk0:

gpt result


Solution 1:

The GUID partition table is a mess.

Just to explain all partitions:

  • i = 1 EFI partition
  • i = 2 main OS X volume (wrong partition type)
  • i = 3 Recovery HD (wrong partition type)
  • i = 4 Windows partition (wrong partition type)
  • i = 5,7 Linux partitions
  • i = 6 Linux Swap partition

I would do the following after booting to Internet Recovery HD:

  1. First you have to unmount disk0 and get the gpt table:

    diskutil umountDisk /dev/disk0
    gpt -r show /dev/disk0
    
  2. Open Utilities->Terminal and remove the two Linux partitions (5,7) and the Linux Swap partition (6) with:

    gpt remove -i 7 /dev/disk0
    diskutil umountDisk /dev/disk0
    gpt remove -i 6 /dev/disk0
    diskutil umountDisk /dev/disk0
    gpt remove -i 5 /dev/disk0
    
  3. Remove the Windows partition (marked as an Apple HFS+ partition)

    diskutil umountDisk /dev/disk0
    gpt remove -i 4 /dev/disk0
    
  4. Remove and properly re-add the Recovery HD:

    diskutil umountDisk /dev/disk0
    gpt remove -i 3 /dev/disk0
    gpt add -b 176870968 -i 3 -s 1269536 -t 426F6F74-0000-11AA-AA11-00306543ECAC /dev/disk0
    
  5. Remove and properly re-add the OS X partition:

    diskutil umountDisk /dev/disk0
    gpt remove -i 2 /dev/disk0
    gpt add -b 409640 -i 2 -s 176461328 -t 48465300-0000-11AA-AA11-00306543ECAC /dev/disk0
    

    the type of the partition may also be 53746F72-6167-11AA-AA11-00306543ECAC (CoreStorage). With on-board tool it's impossible to determine the correct partition type.

  6. Verify disk0 and disk0s2:

    diskutil verifyDisk /dev/disk0
    diskutil verifyVolume /dev/disk0s2
    

    If you get errors you may consider replacing the default partition type of disk0s2 by a CoreStorage volume:

    diskutil umountDisk /dev/disk0
    gpt remove -i 2 /dev/disk0
    gpt add -b 409640 -i 2 -s 176461328 -t 53746F72-6167-11AA-AA11-00306543ECAC /dev/disk0
    

    Enter diskutil cs list. If you get No CoreStorage logical volume groups found as result repeat step 5 and continue with the diskutil verifyDisk... and diskutil repairDisk... steps below. If the diskutil cs list reveals a CoreStorage Volume Group check if it is encrypted: Logical Volume Family -> Encryption: locked. Unlock the volume with: diskutil cs unlockVolume lvUUID with lvUUID: the UUID of the Logical Volume and entering your passphrase.

    Verify disk0 and disk0s2 again:

    diskutil verifyDisk /dev/disk0
    diskutil verifyVolume /dev/disk0s2
    

    If you still get errors try to repair disk0 and disk0s2:

    diskutil repairDisk /dev/disk0
    diskutil repairVolume /dev/disk0s2
    
  7. Quit Terminal by entering exit and try to reboot to your main OS X volume

If you get an error saying disk0 Resource busy... you have to unmount disk0 again with diskutil umountDisk /dev/disk0.