View Single Post
Old September 4th, 2008  
meierfra.
Iced Blended Vanilla Crème Ubuntu
 
Join Date: Apr 2008
Beans: 2,854
Kubuntu 9.10 Karmic Koala
How to fix Vista/Window 7 when the boot files are missing

This HowTo shows how to fix the Vista's Boot Loader when the boot file "bootmgr" is missing. (the same HowTo works for Windows 7. Just replace Vista by Windows 7 everywhere).

Step 1) Edit menu.lst: (Skip this step if you are using Grub 2)

Boot into Ubuntu, open a terminal (Applications->Accessories->Terminal) and type

Code:
gksudo gedit /boot/grub/menu.lst
This opens the file boot/grub/menu.lst.
Add this to the very end of the file

title Vista
rootnoverify (hd0,4)
chainloader +1

Do NOT use "makeactive".
Of course (hd0,4) needs to be adjusted. The first number is the hard drive and the second number the partition. Grubs starts counting at zero, and counts the hard drives according to the order in the Bios. So the boot drive is always (hd0). The second number is always one less than the number in the device name (use "sudo fdisk -lu" to determine the device name). So if Vista is on /dev/sda5, then the second number is 4. The "hd" is always "hd", even if the device name contains "sd".

If Vista is not on the boot drive, you need to add "map" lines:

title Vista
rootnoverify (hd3,4)
map (hd0) (hd3)
map (hd3) (hd0)
chainloader +1

Save the file.

Step 2) Repair the Vista Bootloader.


Boot from a Vista or Windows 7 CD/DVD. If you do not have one, you can download a Vista Recovery CD from here or here, and a Windows 7 CD from here

A Vista DVD can be used for Windows 7 and vice versa. Edit 5/3/09: There is some indication that is no longer true for the most recent version of Windows 7. So I recommend to use a Windows 7 CD/DVD for Windows 7.

There are two ways to repair the Vista Boot Loader: Automatic and Manual. The Automatic repair should work under normal circumstances, but will fail in more complicated situations.

Automatic Repair of the Vista Boot Loader

At the first screen select your favorite language.
At the second screen choose "Repair your Computer".

If a pop windows appears, offering to repair a problem with the "Startup options", click on "Repair and restart".

Otherwise, on the next screen select "Use recovery tools ..." and click on "Next".
Choose "Startup Repair" at the next screen.

"Startup Repair" tends to fix one problem at the time. So you might have to run "Startup Repair" several times.

Manual Repair of the Vista Boot Loader

At the first screen select your favorite language.
At the second screen, select "Install Now"
At the third screen, press "Shift F10".

This will open a terminal. In the terminal type

Code:
 diskpart
and then at the 'diskpart' prompt:

Code:
 list volume
This will list the drive letters for all the 'NTFS' and 'Fat' partitions on your computer. Determine the drive letter for your Vista partition. In the following I'll assume it is "C:". If the drive letter of your Vista partition is different, you need to replace all "C:" accordingly. Also determine the drive letter for the CDrom drive, I'll assume that is "E:". Type

Code:
 exit
to exit the ``diskpart'' prompt.

Type

Code:
copy E:\bootmgr C:\

mkdir C:\BOOT

copy E:\BOOT C:\BOOT 

bcdedit /store C:\boot\bcd /set {default} osdevice boot

bcdedit /store C:\boot\bcd /set {default} device boot

bcdedit /store C:\boot\bcd /set {default} path \Windows\system32\winload.exe

bcdedit /store C:\boot\bcd /set {bootmgr} device boot

bcdedit /store C:\boot\bcd /set {memdiag} device boot
Depending on the DVD you are using you might also have to type the following three lines

Code:
bcdedit /store C:\boot\bcd /deletevalue  {default} detecthal 

bcdedit /store C:\boot\bcd /deletevalue  {default} winpe

bcdedit /store C:\boot\bcd /deletevalue  {default} ems
Just go ahead and type those three lines. But you might get an "element not found" warning, which you can ignore.

Then type:

Code:
E:\boot\bootsect.exe /nt60  C:
This might produce an error message, since some Vista CDs (including the one I linked above) do not come with 'bootsect'. But the command is not always necessary, so just proceed. If after completing the HowTo you get an 'ntldr misssing' message while trying to boot Vista, reply to this thread and ask for help.

If you are using Grub 2: Reboot into Ubuntu and type "sudo update-grub" in a terminal


Reboot and select 'Vista' at the grub menu.

Sometimes this does not work right away and you have to do a third step.


Step 3) Rebuild the Boot Sector of the Vista's partition.


Boot into Ubuntu. (make sure that The Universe Repository is enabled in Systmem->Administration->Software Sources. Then install and run "testdisk via

Code:
sudo apt-get install testdisk

sudo testdisk /dev/sda
(Replace /dev/sda by the device name of the Vista partition without the trailing number)

Press "enter" to "proceed"
Press "enter" to select "intel"
Use the "down arrow" and "enter" to select "advanced"
Use the down error to select the "Vista" partition and then "enter" to select "boot"
Use the "right arrow" key and "enter" to select "Rebuild BS"
This might take a while. Once done just follow the instruction on the screen to save the new boot sector and quit testdisk.

Reboot and select Vista at the Grub Menu.

This HowTo has been applied successfully in many cases, but of course I cannot guarantee that it will work under all circumstances.

For more information on the Vista booting process see Vista_Multi_Booting and EasyBCD

Last edited by meierfra.; 2 Weeks Ago at 10:36 PM.. Reason: Added instruction for Grub2
meierfra. is online now   Reply With Quote