Boot Camp does not boot after disk cloning
Solution 1:
I can see two problems.
- The MBR partition table on disk 1 has the wrong values.
- disk1s1 does not belong and should be removed.
I will show how to fix the first problem.
- Open the Script Editor application and open a new empty window. The preferences show I am using "Script Editor (2.7)" and "AppleScript (2.4)" as defaults.
-
Paste the following code in to the window.
use scripting additions property disk : 1 property mypassword : "" on fixmbr() script tm on subtract(x as text, y as text) return (x - y) as text end subtract on add(x as text, y as text) return (x + y) as text end add end script script mbr property table : {¬ {id:"EE", guid:"C12A7328-F81F-11D2-BA4B-00A0C93EC93B"}, ¬ {id:"07", guid:"EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"}, ¬ {id:"AF", guid:"48465300-0000-11AA-AA11-00306543ECAC"}, ¬ {id:"AB", guid:"426F6F74-0000-11AA-AA11-00306543ECAC"}, ¬ {id:"AC", guid:"53746F72-6167-11AA-AA11-00306543ECAC"}, ¬ {id:"00", guid:"E3C9E316-0B5C-4DB8-817D-F92DF00215AE"}} property entry1 : {id:"00", active:"-", start:"0", size:"0"} property entry2 : {id:"00", active:"-", start:"0", size:"0"} property entry3 : {id:"00", active:"-", start:"0", size:"0"} property entry4 : {id:"00", active:"-", start:"0", size:"0"} property entry : {entry1, entry2, entry3, entry4} on MapGUIDToId(guid as text) repeat with pair in table if guid is guid of pair then return id of pair end repeat log "error" end MapGUIDToId on MapIdToGUID(id as text) repeat with pair in table if id is id of pair then return guid of pair end repeat log "error" end MapIdToGUID end script set output to do shell script "gpt -r show /dev/disk" & disk password mypassword with administrator privileges set AppleScript's text item delimiters to {" "} --, "GPT part -"} set i to 0 set rows to paragraphs in output --showValue of sv for rows set foundActive to false set j to 0 repeat with row in rows set columns to {} repeat with x in text items in row if x is not in {""} then set end of columns to contents of x end if end repeat if length of columns is 7 and {"GPT", "part", "-"} is in columns then --showValue of sv for columns given minCount:12 set i to i + 1 set ind to (item 3 of columns) as integer if i is not equal to ind then log "error" else if j is 0 and item 7 of columns is MapIdToGUID("EE") of mbr then set j to 1 --log "found " & i & " for entry " & j set partStart to item 1 of columns set partSize to item 2 of columns set partSize to add(partSize, partStart) of tm set partStart to "1" set partSize to subtract(partSize, partStart) of tm set id of entry1 of mbr to "EE" set start of entry1 of mbr to partStart set size of entry1 of mbr to partSize else if 0 < j and j < 4 then set j to j + 1 --log "found " & i & " for entry " & j set entry to item j of entry of mbr set id of entry to MapGUIDToId(item 7 of columns) of mbr set start of entry to item 1 of columns set size of entry to item 2 of columns if not foundActive and id of entry is "07" then set active of entry to "*" set foundActive to true end if end if end if end repeat set i to 0 set input to {} repeat with ent in entry of mbr if id of ent is "00" then exit repeat set i to i + 1 set end of input to "edit " & i & linefeed set end of input to id of ent & linefeed set end of input to "n" & linefeed set end of input to start of ent & linefeed set end of input to size of ent & linefeed if active of ent is "*" then set end of input to "flag " & i & linefeed end if end repeat set end of input to "q" & linefeed & "y" & linefeed set AppleScript's text item delimiters to {} set input to input as text --log linefeed & input set command to "fdisk -e /dev/disk" & disk & " << EOF" & linefeed & input & "EOF" log linefeed & command set output to do shell script command with administrator privileges log output display dialog "The script has finished." buttons {"OK"} return 0 end fixmbr fixmbr()
-
Click the "Run" button. The script should prompt you for your login password. When the script finishes, you should get the following pop up window.
-
Quit the Script Editor and enter the following command at a Terminal window.
sudo fdisk /dev/disk1
The result should be the same as shown below.
Disk: /dev/disk1 geometry: 121601/255/63 [1953525168 sectors] Signature: 0xAA55 Starting Ending #: id cyl hd sec - cyl hd sec [ start - size] ------------------------------------------------------------------------ 1: EE 0 0 2 - 1023 254 63 [ 1 - 673791] <Unknown ID> 2: AC 1023 254 63 - 1023 254 63 [ 673792 - 1751953408] <Unknown ID> 3: AB 1023 254 63 - 1023 254 63 [1752627200 - 1269760] Darwin Boot *4: 07 1023 254 63 - 1023 254 63 [1754306560 - 199217152] HPFS/QNX/AUX
If everything worked out, you can quit the Terminal application and try booting Windows. If Windows still will not boot, let me know and we can try to fix the second problem.
Expanation
There are two partition schemes that are important here. They are the Master Boot Record (MBR) partitioning scheme and the Globally Unique Identifier (GUID) partitioning scheme. The MBR scheme contains a MBR Partition Table which allows for the definition of only 4 partitions. The GUID scheme contains the same 4 entry MBR Partition Table and a GUID Partition Table (GPT) whose length is determined at time of creation. This value is typically much larger than 4 entries.
When a disk is partitioned using the GUID scheme, only the first entry is used in the MBR table. On your, disk this table contained the following data.
Disk: /dev/disk1 geometry: 121601/255/63 [1953525168 sectors]
Signature: 0xAA55
Starting Ending
#: id cyl hd sec - cyl hd sec [ start - size]
------------------------------------------------------------------------
1: EE 0 0 2 - 1023 254 63 [ 1 - 1953525167] <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
The id of EE indicates the disk is GUID partitioned and the GPT should be used to determine partitioning. The next six columes (Starting/Ending cyl/hd/sec) exist for legacy purposes. Experience has taught me that on Mac computers, it does not matter what values are in these six columns. In your case, the first three contain the lowest possible valid values and the next three contain the highest possible valid values. What is important is the start and size columns. Your disk is divided into 1953525168 sectors where each sector is 512 bytes. The first sector is numbered 0 and contains the MBR which also contains the MBR table. The partition with the EE id is defined to cover the rest of the disk. This gives older legacy partitioning software the impression all space has been allocated on the disk. This is why you will see the phrase Protective Master Boot Record (PMBR) in other documentation.
Below is a partial list of the contents of the GPT on your disk.
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 262144 1 GPT part - E3C9E316-0B5C-4DB8-817D-F92DF00215AE
262178 2014
264192 409600 2 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
673792 1751953408 3 GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
1752627200 1269760 4 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
1753896960 409600
1754306560 199217152 5 GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
1953523712 1423
1953525135 32 Sec GPT table
1953525167 1 Sec GPT header
Each table entry is 128 bytes long. Since the table occupies 32 sectors, one can compute the table can hold around 32 * 512 / 128 = 128 entries. (Actually, 128 is the default according to the man page documentation.) Note, there is a backup table/header at the end of the disk. The GUID's correspond to the following types of partitions.
E3C9E316-0B5C-4DB8-817D-F92DF00215AE = Microsoft Reserved
C12A7328-F81F-11D2-BA4B-00A0C93EC93B = EFI
53746F72-6167-11AA-AA11-00306543ECAC = Apple_CoreStorage
426F6F74-0000-11AA-AA11-00306543ECAC = Apple_Boot
EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 = Microsoft Basic Data
Normally, the Disk Utility application hides the EFI and Apple_Boot partitions. The Microsoft Reserved partition does not belong and should be removed. The EFI partition usually occurs first. It is not used to boot the OS X operating system, but is required by OS X for other uses. The Apple_CoreStorage partition contains most of your OS X "Macintosh FD" volume. The Apple_Boot partition (I believe) contains your "Bootable Recovery Partition". The software, contained in this partition, is the replacement for the recovery software that was on the installation DVD. Finally, Microsoft Basic Data partition contains your Windows volume.
On your Mac, Windows requires a MBR scheme which is a conflict since OS X uses a GUID scheme. The following changes were necessary to the MBR partition table to fool Windows in to thinking your computer is using a MBR scheme.
- The size of the EE partition was adjust to just cover the EFI partition.
- Data was copied from the GPT to the MBR partition table. The was done for first three partitions that followed the EFI partition. In your case, this was the rest of the partitions. The start and size were copied exactly. Each GUID was translated to an id. I would give a translation table, but unfortunately not all the translations are one-to-one.
- The windows partition was marked as active. Active means boot to this partition. When printing the MBR partition table, the active partition is marked with an * character.
When corrected the MBR partition table should appear as follows.
Disk: /dev/disk1 geometry: 121601/255/63 [1953525168 sectors]
Signature: 0xAA55
Starting Ending
#: id cyl hd sec - cyl hd sec [ start - size]
------------------------------------------------------------------------
1: EE 0 0 2 - 1023 254 63 [ 1 - 673791] <Unknown ID>
2: AC 1023 254 63 - 1023 254 63 [ 673792 - 1751953408] <Unknown ID>
3: AB 1023 254 63 - 1023 254 63 [1752627200 - 1269760] Darwin Boot
*4: 07 1023 254 63 - 1023 254 63 [1754306560 - 199217152] HPFS/QNX/AUX
The command that was used to make the changes to this table on your disk is called fdisk
. The values for the Starting/Ending cyl/hd/sec where chosen by the command. Other than flagging partition 4 as active, the script you ran only entered the id, start and size values.
To be more precise, the exact command was sudo fdisk -e /dev/disk1
. The interactive commands were edit
, flag
and quit
. A description of fdisk
can be found at this OS X Man Page. (Or by typing man fdisk
in a Terminal window.)
Solution 2:
According to Apple, you must use BootCamp to initialize a Windows partition or it won't work.
I suggest you do the following.
Get WinClone if you don't already have it. The best way to back up your BootCamp partition. http://twocanoes.com/winclone/
Use WinClone to back up your BootCamp partition.
Initialize your new hard disk to Mac OS X.
Use BootCamp Assistant to create new Windows partition (will install blank windows OS).
Use WinClone to restore old BootCamp backup to virgin Windows partition.
I just did this process because I had to expand my BootCamp partition and it worked great.