9
8
I have had the misfortune to need to clone a dual-booting Windows XP/7 box to replace its hard drive with a smaller one. I had great trouble getting it to boot and would like to understand what's going on and if I could be doing anything better.
Background: the machine has a 750Gb drive with 3 partitions on it:
- Windows XP
- Windows 7
- Data
The original installation was done in such a way that there is no separate Windows 7 recovery partition. I hope this fact simplifies things somewhat.
I am replacing it with an 80Gb drive. The partitions have already been shrunk from within Windows 7 so that they fit onto the smaller disk.
I used GParted
(from a PartedMagic
Linux LiveCD) to copy the partitions across. I mark the Windows XP partition as the active partition (the same as on the original disk).
I was unable to use CloneZilla
or do an entire disc copy due to the transition from a larger to a smaller disk.
After copying the partitions, I manually copied the boot loader across (taking care not to copy the partition table):
$ dd if=/dev/sda of=/dev/sdb bs=446 count=1
I removed the original disk, set the new one so it is physically connected the same as the original (IDE channel 1 master) and tried booting. This successfully presented the boot menu but failed upon selecting either option (there are two: one for XP and one for Win7).
I did a fair bit of research which let me to realise the Windows 7 boot configuration data did not contain everything it should. I compared the BCD output from the original and new disks and noted that the device entries on the latter were unknown
. So I manually changed them to match the original - like this:
$ bcdedit /set {ntldr} device partition=C:
$ bcdedit /set {default} device partition=D:
$ bcdedit /set {default} osdevice partition=D:
and rebooted. This time I could boot both XP and Win7. I need to do more testing because there appears to be other differences between the two BCDs, but making the above changes at least allowed booting to take place.
So my question is really to ask why the BCD on a cloned partition would appear different to the original, and sufficiently so to prevent booting ?
And a follow up to that would be to ask if I should be doing this another way?
Note that
bcdboot
provides an easier way to recreate a boot entry, but I'm not sure it would be suitable in a XP/W7 dual-boot scenario. – Harry Johnston – 2013-06-06T05:22:44.287I love your answer, but could you please clean it up a bit? I think there's a lot of extraneous information (such as example commands, when you have the actual command right after, etc.). – Bigbio2002 – 2013-06-25T20:22:04.277
I'm glad you like the anser but I don't think there's a lot of extraneous info in there. I have a general explanation plus one real example at the end which actually demonstrates how to determine the partitions fro each entry that needs to be changed. I needed all of the above knowledge to fix up my cloned system and, so, presented it as an answer in full to provide as much information to others. – starfry – 2013-06-29T07:23:26.563