Some days ago, I installed Ubuntu on my MacBookPro, I created a new partition shrinking the one I was using for MacOS.
Later I decided to remove it, so I deleted the partition containing Ubuntu, but I didn't manage to resize the MacOS partition back to the start, so I booted in Recovery Mode to do that. Then I realized that my battery was going low and I closed the MacBook lid to do that in another moment.
The day after I opened my lid, I heard the Mac sound and the missing boot icon appeared.
Now if I go to Recovery Mode, I can see the hard drive but the partition with MacOS is greyed out, and I don't know how to fix this.
Here is the output of diskutil list
:
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *251.0 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_UFS 180.8 GB disk0s2
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: Apple_partition_scheme *1.3 GB disk1
1: Apple_partition_map 30.7 KB disk1s1
2: Apple_HFS OS X Base System 1.3 GB disk1s2
/dev/disk2
#: TYPE NAME SIZE IDENTIFIER
0: untitled *5.2 MB disk2
/dev/disk3
#: TYPE NAME SIZE IDENTIFIER
0: untitled *524.3 KB disk3
/dev/disk4
#: TYPE NAME SIZE IDENTIFIER
0: untitled *524.3 KB 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 *6.3 MB disk8
/dev/disk9
#: TYPE NAME SIZE IDENTIFIER
0: untitled *2.1 MB disk9
/dev/disk10
#: TYPE NAME SIZE IDENTIFIER
0: untitled *1.0 MB disk10
/dev/disk11
#: TYPE NAME SIZE IDENTIFIER
0: untitled *524.3 KB disk11
/dev/disk12
#: TYPE NAME SIZE IDENTIFIER
0: untitled *524.3 KB disk12
/dev/disk13
#: TYPE NAME SIZE IDENTIFIER
0: untitled *1.0 MB disk13
/dev/disk14
#: TYPE NAME SIZE IDENTIFIER
0: untitled *6.3 MB disk14
and 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 353106320 2 GPT part - 55465300-0000-11AA-AA11-00306543ECAC
353515960 136718759
490234719 32 Sec GPT table
490234751 1 Sec GPT header
Best Answer
The second 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 55465300-0000-11AA-AA11-00306543ECAC designates an Apple UFS partition.
It's unclear what happened to the Recovery HD partition.
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 enter
sudo dd if=/dev/diskXsY count=3 | hexdump
.The GUID can be modified with
gpt
. Modifying the GUID partition table with gpt requires to unmount the whole disk which can't be done if you boot to its Recovery HD or another boot volume on the same disk.hexdump
. You may have to install a full bootable OS X to a thumb drive (>16 GB) - an OS X installer thumb drive isn't sufficient!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)
diskutil umountDisk disk0
if booted to an external disk/thumb drive with a full OS X/macOSQuick check if the 1269536 blocks following disk0s2 are a Recovery HD:
If the volume verification doesn't reveal an error you probably recovered a deleted Recovery HD. If you get an error just remove the third partition again:
hexdump the first 3 blocks of the Apple UFS partition:
The following result identifies it as a normal OS X partition:
The first number is the byte count in hex: 0000000: 0; 0000600: 1536. The * denotes identical lines. This means: the first two blocks (0x000-0x3ff) are all zeros.
A CoreStorage partition shows some non-zeros in the first block (0x000-0x1ff):
The line starting with byte 0x130 shows the UUID of the Physical Volume, the line starting with byte 0x140 shows the UUID of the Logical Volume Group.
The string 48 46 53 4a (= "HFSJ") in the first 16 bytes of the third blocks identifies a Journaled HFS+ volume.
Remove the second partition:
re-add the partition with the proper type
either a normal OS X partition
or (if you have found a CoreStorage partition)
Finally verify the disk with
diskutil verifyDisk disk0
and/ordiskutil verifyVolume disk0s2
. If a partition/file system error is reported, add a comment here, but don't actually repair, initialize or copy anything.