OS X – Recovering or Fixing Partition

bootdisk-utilitymacospartitionrecovery

I'm coming from Super User Community, since I wasn't aware of this specific one.
My first and foremost care is the files on my system, I have been slacking on making backups (I know, it's really bad) and I really would at least want to transfer my files before I fully reinstall my system.

This was my original problem (still kind of is): After 'removing' Ubuntu from MacBook it cannot boot to OSX but loads Grub 2

Summary: I had a dual-boot OSX/Ubuntu, tried to remove Ubuntu, messed something up with the original Mac OS partition, can't boot or use the Mac OS (or any OS, since Ubuntu was cleared)

I made a Yosemite Boot USB and started up Disk Utilities from that:

  • I see my MAC OS is now called 'disk0s2' and is greyed out
  • It had no partition type
  • I cannot use the functions: Activate (it does nothing), Activate
    journaling, Convert or Schijf-EHBO (not sure what it's called in
    english but is probably Disk Repair).

This is the information from disk0s2 and the Disk Utility screen:

(had to remove because I dont have enough reputation)

Is there any way I can repair this partition? Can I change its structure to what it was previously, soI can atleast grab some files from there?

Other info:

  • I have a MacBook Pro Retina (2010)
  • Before the crash it ran El Capitan
  • Partition 'Naamloos' might've been part of the Mac OS parition?
  • Recovery HD has been started up from but it cannot load my OS. (read
    my other post)

EDIT1: I might have the same problem as here as some others

Additional info:

diskutil list:

/dev/disk0 (internal, physical):

   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF               239.9 GB   disk0s2
   3:                  Apple_HFS Recovery HD             650.0 MB   disk0s3
   4:                  Apple_HFS Naamloos                10.1 GB    disk0s4
/dev/disk1 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        +2.1 GB     disk1
   1:                  Apple_HFS OS X Base System        2.0 GB     disk1s
/dev/disk2 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               +5.2 MB     disk2

gpt -r show disk0:

      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  468597448      2  GPT part - FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
  469007088    1269536      3  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  470276624   19695313      4  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  489971937     262782         
  490234719         32         Sec GPT table
  490234751          1         Sec GPT header

dd if=/dev/disk0s2 count=3 | vis -c:

3+0 records in
3+0 records out
1536 bytes transferred in 0.000682 secs (2252605 bytes/sec)
\^U\^D\^A\M-s\M^?\M^?\M^?\M^?\^A\0\^P\0\0\0\M-W\^A\a\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\^B\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\M^Pu\M-\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0CS\^A\0\0\0\^D\0\0\^P\0\0\0\0@\0X\M-7}\^C\0\0\0\0X\M-;}\^C\0\0\0\0X\M-?}\^C\0\0\0\0X\M-C}\^C\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\^P\0\0\0\^B\0\0\0006j v\^R\M-+\^U\M^[\f\M^CdG\M-y\^]  K\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0=\^A\M-_\M-;\^Y)E\M-I\M-5\M-.<V\M-X\M^K\M-)\M-&\^Z\M-[\M^L\^_\M-$eC\M-&\M^I5\M-l\M^B\M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0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0`

EDIT4:

These messages were shown after doing the removing and readding the partitions:

http://imgur.com/a/nVN0j

The diskutil list after all the steps in @klanomaths answer (thanks for all the help by the way!)

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage                         239.9 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:                  Apple_HFS Naamloos                10.1 GB    disk0s4
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *61.8 GB    disk1
   1:                        EFI EFI                     209.7 MB   disk1s1
   2:                  Apple_HFS Install OS X Yosemite   61.5 GB    disk1s2
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     Apple_partition_scheme                        *6.0 GB     disk2
   1:        Apple_partition_map                         30.7 KB    disk2s1
   2:                  Apple_HFS OS X Install ESD        6.0 GB     disk2s2
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     Apple_partition_scheme                        *1.3 GB     disk3
   1:        Apple_partition_map                         30.7 KB    disk3s1
   2:                  Apple_HFS OS X Base System        1.3 GB     disk3s2
/dev/disk4
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               *5.2 MB     disk4
/dev/disk5
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               *524.3 KB   disk5
/dev/disk6
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               *524.3 KB   disk6
/dev/disk7
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               *524.3 KB   disk7
/dev/disk8
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               *524.3 KB   disk8
/dev/disk9
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               *524.3 KB   disk9
/dev/disk10
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               *6.3 MB     disk10
/dev/disk11
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               *2.1 MB     disk11
/dev/disk12
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               *1.0 MB     disk12
/dev/disk13
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               *524.3 KB   disk13
/dev/disk14

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:                            untitled               *524.3 KB   disk14

/dev/disk15
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               *1.0 MB     disk15
/dev/disk16
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            untitled               *6.3 MB     disk16
Offline
                                 Logical Volume Macintosh HD on disk0s2
                                 71A45184-6D4E-4159-8EFA-3DEC31F9C958
                                 Locked Encrypted

Also, the disk0 show:

-bash-3.2# gpt -r show disk0

      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  468597448      2  GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
  469007088    1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  470276624   19695313      4  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  489971937     262782         
  490234719         32         Sec GPT table
  490234751          1         Sec GPT header

Best Answer

To add an answer exactly fitting to your case I slightly modified my answer in the linked "duplicate" and posted it here again.


The second as well as the third partition of your internal disk got the wrong partition type, your data probably won't be lost.

A bootable OS X partition (except the Recovery HD) either has the GUID 48465300-0000-11AA-AA11-00306543ECAC for a standard OS X partition or the GUID 53746F72-6167-11AA-AA11-00306543ECAC for a CoreStorage partition. The FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF is an unknown partition type (but not no partition like the 000000-0000-0000.... one).

The first block of a standard OS X partition doesn't contain non-zeros, the first block of a CoreStorage partition contains some non-zeros. To get the first 3 blocks of a partition you have to use a substitute for hexdump/xxd (both aren't available in Recovery Mode/OS X Installer boot drive). The best I have found is dd if=/dev/diskXsY count=3 | vis -c.

The GUID partition table can be modified with gpt. gpt only writes to the first 34 and the last 33 blocks of a disk(512) or the first 6 and and last 5 blocks of a 4k disk. Modifying the partition table (even falsely) doesn't alter the content of any volume on your disk, if you don't intialize or repair a volume/disk by request. You may verify it though.


  • Boot to your OS X Installer boot drive
  • Open Terminal in the menubar Utilities > Terminal
  • Get an overview with diskutil list
  • Get an overview of your internal disk with the disk identifier found in the previous command. Below I assume the disk identifier of your internal disk is disk0 (replace it with the one you have found in your environment)

    gpt -r show disk0
    
  • Unmount disk0 with diskutil umountDisk disk0
  • vis the first 3 blocks of the FFFF... partition:

    dd if=/dev/disk0s2 count=3 | vis -c
    
    1. If you had a standard partition previously the first 1024 Bytes only contains non-printable (zeros): \0\0... After ~Byte 1030 you will see the following sequence: \0HFSJ\0

    2. If you had a CoreStorage partition some non-zeros in the first 512 Bytes and the string CS (...\0CS\^A...) are shown:

      \^U\^D\^A\M-s\M^?\M^?\M^?\M^?\^A\0\^P\0\0\0\M-W\^A\a\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\^B\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\M^Pu\M-\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0CS\^A\0\0\0\^D\0\0\^P\0\0\0\0@\0X\M-7}\^C\0\0\0\0X\M-;}\^C\0\0\0\0X\M-?}\^C\0\0\0\0X\M-C}\^C\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\^P\0\0\0\^B\0\0\0006j v\^R\M-+\^U\M^[\f\M^CdG\M-y\^]...
      
  • Now remove the second and the third partition:

    diskutil umountDisk disk0
    gpt remove -i 2 disk0
    gpt remove -i 3 disk0
    

    If you get an error message like "resource busy" just unmount the disk again or unmount stubborn volumes with diskutil umount disk0sX.

    Re-add the recovery partition with the proper type:

    gpt add -i 3 -b 469007088 -s 1269536 -t 426F6F74-0000-11AA-AA11-00306543ECAC disk0
    

    Re-add the main partition with the proper type:

    Either a normal OS X partition (if you have found the typical traces of a normal partition in the dd ... vis step):

    gpt add -i 2 -b 409640 -s 468597448 -t 48465300-0000-11AA-AA11-00306543ECAC disk0
    

    or (if you have found the typical traces of a CoreStorage partition):

    gpt add -i 2 -b 409640 -s 468597448 -t 53746F72-6167-11AA-AA11-00306543ECAC disk0
    
  • Your disk should finally look like this if you have found a standard OS X partition:

        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  468597448      2  GPT part - 48465300-0000-11AA-AA11-00306543ECACC
    469007088    1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
    470276624   19695313      4  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
    489971937     262782         
    490234719         32         Sec GPT table
    490234751          1         Sec GPT header
    

    or this, if you have found a CoreStorage volume:

        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  468597448      2  GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
    469007088    1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
    470276624   19695313      4  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
    489971937     262782         
    490234719         32         Sec GPT table
    490234751          1         Sec GPT header
    
  • Finally verify/repair the disk with diskutil verifyDisk disk0 and/or diskutil verifyVolume disk0s2. If a repair is needed use repair (instead of verify) as prefix in the above commands but contact me before repairing it and send me the error message.