My Windows partition disappeared after resizing it. I found a post on NERDr with a walkthrough for how to fix it and I did everything. This is what I got in my terminal:
Enter an MBR hex code (default AF): 07
Set the bootable flag? (Y/N): y
Unused partition space(s) found. Use one to protect more partitions? (Y/N): n
Recovery/transformation command (? for help): o
Disk size is 490234752 sectors (233.8 GiB)
MBR disk identifier: 0x0566FE4C
MBR partitions:
Number Boot Start Sector End Sector Status Code
1 1 133448879 primary 0xEE
2 * 133448880 489972567 primary 0x07
Recovery/transformation command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/disk0.
Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Unable to open device '/dev/disk0' for writing! Errno is 1! Aborting write!
Recovery/transformation command (? for help):
The problem is the second to last line, says the action was aborted because the disk cannot be opened.
Some partition map details:
Andrews-MBP:~ Drew$ sudo fdisk /dev/disk0
Disk: /dev/disk0 geometry: 30515/255/63 [490234752 sectors]
Signature: 0xAA55
Starting Ending
#: id cyl hd sec - cyl hd sec [ start - size]
------------------------------------------------------------------------
1: EE 1023 254 63 - 1023 254 63 [ 1 - 490234751] <Unknown ID>
2: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
3: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
4: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
Andrews-MBP:~ Drew$ sudo gpt -vv -r show /dev/disk0
gpt show: /dev/disk0: mediasize=251000193024; sectorsize=512; blocks=490234752
gpt show: /dev/disk0: PMBR at sector 0
gpt show: /dev/disk0: Pri GPT at sector 1
gpt show: /dev/disk0: Sec GPT at sector 490234751
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 131769704 2 GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
132179344 1269536 3 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
133448880 356523688 4 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
489972568 262151
490234719 32 Sec GPT table
490234751 1 Sec GPT header
I also have some replies in Official Apple Support Forum, but in a hurry to fix this so I also posted it here.
Best Answer
The 4th partition got the wrong partition type. It's marked as an HFS+ partition, it should be Microsoft Basic Data though.
diskutil list
and with the disk identifier of the internal disk found there:gpt -r show diskX
. Usually it's disk0 - below I assume it's disk0. Use the disk identifier you have found in your environment in the commands below! You also have a CoreStorage volume (e.g. FileVault). Check its disk identifier also. Below I assume it's disk2. If you haven't mounted it (because you didn't unlock it - if it is encrypted), you don't have to unmount it below.Unmount the logical volume and then the internal disk:
Remove the fourth partition:
Re-add the 4th partition with the same first block and size but with the proper type: