Friday, September 7, 2012

Greg’s Guide on Repairing Windows 7 Boot Record

Windows 7 is a masterfully crafted piece of modern software, but I have come across a disturbing glitch in its install process. At install time, if there are any other hard drives or devices that could have Windows potentially installed on them, the boot record for Windows may be incorrectly placed on the wrong hard drive. This can be frustrating because now if the device with the boot record is ever removed or reassigned, Windows will not boot.


Part Zero: Discovery      


After booting into the Windows 7 Repair Menus I went to the command prompt and noticed first that the Windows partition had been relocated to D:\ and the System Reserved partition was the new C:\. Doing a DIR command I found the boot record was located in the System Reserved partition.


Part One: Changing the Partition Letters            


The Windows partition needs to be labeled as the C:\ drive and mark it active. This is done via command prompt using the DISKPART utility. The commands are as follows:


x:\<source>\diskpart                     -- starts DISKPART


DISKPART list volume                     --lists the partitions, use this menu to identify the volume #/letter


DISKPART select volume 2           -- # will vary based on the list volume menu


DISKPART remove letter=C         --letter will vary based on list volume menu


DISKPART inactive                           --marks partition as inactive


DISKPART select volume 1           --changing partition to re-assign drive letter


DISKPART assign letter=C             --changes partition to C:


DISKPART active                               --this ensures partition is marked active


DISKPART rescan                              --refreshes partition info


DISKPART list volume                     --confirm the changes made


DISKPART exit                                   --leaves DISKPART utility


Part Two: Moving Boot.sec to the Proper Location


That is certainly a lot of commands to swap drive letters between partitions, but now the boot record does not match the partition labels! This can be confirmed via X:\sources\bcdedit command. At this point, the easiest way to resolve this is to copy the boot folder and the boot.sec file to the correct partition. For this I used MiniXP on the Hirens Boot CD.  Once you have confirmed the new location, reboot into the Windows 7 Repair Console and open command prompt again.


Part Three: Rebuilding the Boot Record              


The last portion will force a rebuild of the boot record and rediscover where Windows is actually located. In command prompt:


C:                                                            --change drive letter


cd boot                                                 --navigate to the boot folder


attrib bcd –s –h –r                           --necessary attribute changes


ren c:\boot\bcd bcd.old                                --back up old BCD file renaming it bcd.old


bootrec /rebuildbcd                       --rebuilds bcd file. May prompt to confirm Windows location


Part Four: Follow up     


After that, the system should boot into Windows. It may want to run a system startup repair, which is fine.  I have found that I still need to remove a drive letter from the System Reserved partition via Disk Management. Now the partition letters as well as the Boot Record are all accurate.

As a reminder, remove all unnecessary drives from the computer when installing Windows 7.

No comments:

Post a Comment