How To Fix Broken GPT, GUID and Unmountable, No Type Volumes?
How To Fix Broken GPT, GUID and Unmountable, No Type Volumes?
_
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
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
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.
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
Progress:
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
Progress 2:
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
Firstly a big thank to @klanomath, without the help, I couldn't go this far.
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
1 Answer
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!):
Then you have to change the content type of the second partition:
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
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
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:
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.:
and add the gpt entries with gpt ... outlined above.
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.
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
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