Mac OS update -Repair bootcamp gap between GPT3 and GPT4

  • Post published:October 30, 2015

Broken BOOTCAMP in OS X 11 El Capitan
——————————————————–
// To prevent from this issue: please do not update OS X if you did a manually resize operation on your already installed bootcamp, unless you did not backup your windows files. or change the way you resize your bootcamp partitition ti the following: backup your windows files, delete the bootcamp partitions with sox’s bootcamp helper – create a new (resized) bootcamp with bootcamp helper – update OS X!

// The following guide adresses MAC setups with a single disk
// If you have a multi disk setup you must adjust the disk<number> where windows and osx is installed at
// If you like me experience the problem that el capitan’s disk util does no longer show your BOOTCAMP partition and you are not able to boot to your windows this guide is for you
// Note: In my opinion technically the problem occurs because of the following: you installed osx than created a bootcamp partition used it, resized it (adjusting free space on the osx partition, resizing it and expanding disk space from windows): this is where the problem starts: osx is not aware of saving the new offsets to the windows partition being expanded. So if you update osx you will likely end in a partly overwritten/repartioned osx recovery partition breaking the offsets to the windows partition and its mbr.
// The following guide helped me to at least boot my BOOTCAMP again and used it as usual. But I highly recommend you to backup your windows files and reinstall your MAC from scratch, once you get it worling again!

(Source: https://discussions.apple.com/thread/7200751)
// Look for anomalies
diskutil list
diskutil cs list
sudo fdisk /dev/disk0

 

// If this shows a gap between GPT3 and GPT4 you are right at this guide!
sudo gpt –v -r show /dev/disk0
// Something like
start size index content
0 1 MBR
1 1 PRI GPT HEADER
2 32 PRI GPT TABLE
34 6
40 5000 1 GPT PART
5000 10000 2 GPT PART
10000 200 3 GPT PART
10200 20000 // GAP WE NEED TO CLOSE
30200 20000 4 GPT PART


//1. So we will first serarch with TESTDISK (http://www.cgsecurity.org/wiki/TestDisk_Download) for the correct offsets

So run a TESTDISK “Quicksearch” on the disk0 (where windows (mbr) and osx is/was at) – this could take 1hour depending on your disk’s size
If you have the results you should see a list of partiiton entries

1

By pressing “p” you can see the files stored on each partition
Try to find the partition with windows installed “System Volume Information” is a good indicator for this
If you have found the right partition note the offsets on top (e.g.):
start end size
12345 67891 55546

!!! Backup (Copy and paste) the output of ther terminal, as we NEED it later on! Especially the offset are important for the next step (here: 12345, 67891, 55546)!!

2

 

//2. We must rearrange the partitons correctly with the tool GPT FDISK (http://sourceforge.net/projects/gptfdisk/files/latest/download)
In order to install gpt’s fdisk we must DISABLE os x’s CSR (Configuring System Integrity Protection – since el capitan)
– restart your mac press “cmd + r” boot into recovery mode – open terminal – type “csrutil disable” (without “”)
– restart your mac and install gpt fdisk

3
– run gpt fdisk: “sudo gdisk /dev/disk0”
– press “p” which prints the list of all partitions
– press “d” to enter delete mode of partitions
– press “4” to delete partition 4 – remember this is for the specific case noted above – adjust it to your own specific case, but normally you will only have 4 partitons because this is the allowed default with bootcamp and osx!

4
– press “n” to create new partition
– press “4” to select the number of the partition we want to create
– now we must enter th start point/offset of our bootcamp partition, this is the previously saved offset from our windows partition we found with testdisk
12345
– now we must enter the size of our bootcamp partition leaded by a “+” sign as we want to add the size to our starting point, this is the previously saved offset from our windows partition we found with testdisk
+55546

5
– now we set the type to be a windows partition by typing: “0700”
– press “p” to again list all partitions and to monitor what will be written to the partition table (check our changes of correctness)
– press “w” to write our new gpt table
– press “y” to verify the writing of the gpt partition table

9910

 

//3. Now we must recover/rebuild the mbr to be able to boot to windows again
if you restart at this point you will not be able to boot to windows, but you should see your bootcamp partition within diskutil
in order to get windows to boot agein we must consider th following steps: run gpt fdisk again:
– open terminal and run “sudo gdisk /dev/disk0”
– press “p” to list all your partitions, needed to be able to select all numbers of partitions that need to be added to the mbr
– press “r” to get into recovery mode
// this is confusing – press “o” to print current mbr setup
– press “h” to create new mbr setup
– type all partitions numbers, except EFI, that need to be added (osx, recover, bootcamp): if you have a default osx/bootcamp setup with a max of 4 partitions you should enter 2 3 4 (see output of step “p” to find your partition index numbers)
– press “y” to support grub bootloader too
– press enter to select default “AF” for gpt1
– press “n” to ignore osx from mbr, because mbr can only boot to windows
– press enter to select default “AB” for gpt2
– press “n” to ignore recover from mbr, because mbr can only boot to windows
– press enter to select defautl “07” for gpt3
– press “y” to add this partition as a bootable marked partition to the mbr
– press “o” to print current mbr setup (check if all changes are correct, there should be a kleene star* ath the windows partition gpt3, marking this as bootable partition)
– press “w” to write the changes to our newly created mbr
– press “y” to verify the writing of the mbr partition table
– reboot

 

//4. check if you can access COOTCAMP partiiton within osx
Check if you can boot to windows again


//5. Reactivate CSR
– ENABLE os x’s CSR (Configuring System Integrity Protection – since el capitan)
– restart your mac press “cmd + r” boot into recovery mode – open terminal – type “csrutil enable” (without “”)
– reboot