How to fix broken GPT, GUID and unmountable, no type volumes?
Solution 1:
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 likegpt ...
!
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 prependsudo
using thefdisk ...
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 like499g
or499500m
.diskutil cs resizeStack lvUUID 500g