sign up log in tour help
_
Ask Different is a question and answer Here's how it works:
site for power users of Apple hardware
and software. Join them; it only takes a
minute:
Sign up Anybody can ask Anybody can The best answers are voted
a question answer up and rise to the top
How to fix broken GPT, GUID and unmountable, no type volumes?
I have a Macbook Pro with retina, Yosemite and 500GB hard drive. I tried to install Windows using Bootcamp and accidentally deleted a
partition, now my Mac cannot boot anymore. This is the output from sudo gpt -r show disk0
gpt show: disk0: Suspicious MBR at sector 0
start size index contents
0 1 MBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
409640 776617328 2 GPT part - FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
777026968 1269760 3 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
778296728 616
778297344 198807552 4 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
977104896 131
977105027 32 Sec GPT table
977105059 1 Sec GPT header
I only need to make the second partition at index 2 and type FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF to be bootable again. This partition has
FileVault 2 enabled.
But right now, I have no clue on what to do.
P/S: I Followed the instruction from @klanomath Boot from a external hard drive with full Yosemite system but at the last command to change
the partition type
sudo gpt add -b 409640 -s 776617328 -i 2 -t 53746F72-6167-11AA-AA11-00306543ECAC
/dev/disk0
It got this error:
gpt add: /dev/disk0: Suspicious MBR at sector 0
gpt add: /dev/disk0: error: no space available on device
This is the output from sudo gpt -r show /dev/disk0
gpt show: /dev/disk0: Suspicious MBR at sector 0
start size index contents
0 1 MBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
409640 776617328 2 MBR part 218
777026968 1269760 3 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
778296728 616
778297344 198807552 4 MBR part 175
977104896 131
977105027 32 Sec GPT table
977105059 1 Sec GPT header
Progress:
I have executed command sudo gpt destroy /dev/disk0
But when I tried to add the first partition back using this command sudo gpt add -b 40 -s 409600 -i 1 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B
/dev/disk0
I got this error straight away
gpt add: /dev/disk0: Suspicious MBR at sector 0
gpt add: /dev/disk0: error: no primary GPT header; run create or recover
Now the command sudo gpt -r show /dev/disk0 gives me this
gpt show: /dev/disk0: Suspicious MBR at sector 0
start size index contents
0 1 MBR
1 409639
409640 776617328 2 MBR part 218
777026968 1269760 3 MBR part 175
778296728 616
778297344 198807552 4 MBR part 175
977104896 164
Progress 2:
I executed sudo gpt create /dev/disk0 and got this error:
gpt create: /dev/disk0: Suspicious MBR at sector 0
gpt create: /dev/disk0: error: device contains a MBR
and I executed this command sudo fdisk -i -a hfs /dev/disk0 to write new MBR and executed sudo gpt create /dev/disk0 again but got the
same error gpt create: /dev/disk0: error: device contains a MBR
Now sudo gpt -r show /dev/disk0 gives me this
start size index contents
0 1 MBR
1 62
63 977104997 1 MBR part 175
Progress 3 and final :D
Firstly a big thank to @klanomath, without the help, I couldn't go this far.
I executed this command sudo gpt create -fp /dev/disk0
And this command sudo gpt recover /dev/disk0 to get the secondary GPT header
After that, I executed sudo gdisk /dev/disk0 and the disk is mounted and functions properly
macbook yosemite mount efi guid
edited Dec 28 '15 at 7:07 asked Dec 27 '15 at 13:55
Leon Nguyen
187 2 7
1 Answer
The content type of the second partition is wrong. Instead of FFFFFFFF-FFFF-FFFF-FFFF-
FFFFFFFFFFFF it has to be 53746F72-6167-11AA-AA11-00306543ECAC.
To edit the content type you have to boot to Internet Recovery Mode and use gpt . Additionally
the fourth partition will be removed (probably the "deleted" partition). Please check that it
doesn't contain any data!
Preparation:
Detach any external drive (especially your external Time Machine backup drive)
Restart to Internet Recovery Mode by pressing alt cmd R at startup.
The prerequisites are the latest firmware update installed, either ethernet or WLAN
(WPA/WPA2) and a router with DHCP activated.
On a 50 Mbps-line it takes about 4 min (presenting a small animated globe) to boot into a
recovery netboot image which usually is loaded from an Apple/Akamai server.
I recommend ethernet because it's more reliable. If you are restricted to WIFI and the boot
process fails, just restart your Mac until you succeed booting.
Alternatively you may start from a bootable installer thumb drive (preferably Yosemite or El
Capitan) or a thumb drive containing a full system (preferably Yosemite or El Capitan). If
you boot to a full system and login as admin you have to prepend sudo to execute special
commands like gpt ... !
Remove the fourth partition and change the content type of the second partition
Booted to Internet Recovery Mode open Utilities Terminal in the menubar and enter:
diskutil list to get the disk identifiers. Below I assume that your main disk has the disk
identifiers disk0.
First you have to remove the fourth partition (only do that if it is really empty!):
gpt -r show /dev/disk0 #to get an overview
To delete a partition with gpt the disk has to be unmounted:
diskutil unmountDisk /dev/disk0
gpt remove -i 4 /dev/disk0 #remove the fourth partition
Then you have to change the content type of the second partition:
diskutil unmountDisk /dev/disk0
gpt remove -i 2 /dev/disk0 #remove the second partition
gpt add -b StartBlock -s NumberOfBlocks -i 2 -t 53746F72-6167-11AA-AA11-00306543ECAC
In your case:
gpt add -b 409640 -s 776617328 -i 2 -t 53746F72-6167-11AA-AA11-00306543ECAC /dev/disk0
Now you should be asked for the FileVault passphrase. Enter it.
Enter exit and quit Terminal
Check the main volume Macintosh HD for errors
Quit Disk Utility and reboot to your main volume
Addendum: Removing the stubborn MBR
You can either use fdisk or gpt to remove the MBR at block 0. If you use an admin user
prepend sudo using the gpt .... commands.
First get an overview again. This step is important before you destroy the gpt, because it's
the source to rebuild it from scratch:
gpt -r show /dev/disk0
Then delete the gpt:
diskutil unmountDisk /dev/disk0
gpt destroy /dev/disk0
Create a new GUID partition table:
gpt create -f /dev/disk0
Finally add all partitions one by one:
gpt add -b 40 -s 409600 -i 1 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B /dev/disk0
gpt add -b 777026968 -s 1269760 -i 3 -t 426F6F74-0000-11AA-AA11-00306543ECAC /dev/disk0
gpt add -b 409640 -s 776617328 -i 2 -t 53746F72-6167-11AA-AA11-00306543ECAC /dev/disk0
Hint: You may add and remove partitions in an arbitrary order if you keep the right index
number. In the above commands I added the third partition ( ... -i 3 ... ) before adding
the second partition ( ... -i 2 ... ). You don't have to unmount disk0 then because the
partitions i=1 and i=3 don't contain auto-mounted volumes while the second partition does.
I missed to detect the wrong partition type of your Recovery HD (the third partition with
the index number 3) in the first part of my answer. Therefore I used:
gpt add -b 777026968 -s 1269760 -i 3 -t 426F6F74-0000-11AA-AA11-00306543ECAC /dev/disk0
above instead of the wrong
gpt add -b 777026968 -s 1269760 -i 3 -t 48465300-0000-11AA-AA11-00306543ECAC /dev/disk0
#wrong partition type of the Recovery HD
to re-add it.
If you still get errors, tackle the MBR with fdisk . If you use an admin user prepend sudo
using the fdisk ... commands.:
fdisk -i -a hfs /dev/disk0
and add the gpt entries with gpt ... outlined above.
Resizing the main volume to fill the whole disk
Finally you probably want to resize the main volume to fill the whole disk.
Get an overview with:
diskutil cs list
You may have several CoreStorage Logical Volume Groups, if you boot from an external
drive with a full system! Use the proper one!
Resize the whole stack:
diskutil cs resizeStack lvUUID size #lvUUID is the UUID of the Logical Volume. Usually
it's the last one listed.
Booted to Yosemite you can use 0g for the size to expand it. 0g is a "magical" size here.
diskutil cs resizeStack lvUUID 0g
Booted to El Capitan you have to use a real size like 500g . If you get an error use a
slightly smaller size like 499g or 499500m .
diskutil cs resizeStack lvUUID 500g
edited Jun 9 '16 at 4:59 answered Dec 27 '15 at 14:51
klanomath
30.6k 5 35 77
I'm still stuck. Firstly, after executing "gpt delete -i 2 /dev/disk0", it said "gpt: unknown command: delete" so I assume
that I need to change 'delete' to 'remove'. But at the last command that I need to execute, it said "gpt add: /dev/disk0:
error: no space available on device" Leon Nguyen Dec 28 '15 at 1:27
I have followed your instruction and posted the results in the question, thanks Leon Nguyen Dec 28 '15 at 1:48
I have followed the second instruction, unfortunately I'm stuck again with the error "gpt add: /dev/disk0: error: no
primary GPT header; run create or recover". I have added the progress Leon Nguyen Dec 28 '15 at 6:33
no worries, I just updated my progress. looks like I couldn't get rid of the MBR Leon Nguyen Dec 28 '15 at 6:47
I have successfully recover the stubborn FileVault, you may want to update your answer with my final progress, thanks
so much :D Leon Nguyen Dec 28 '15 at 7:08