Page 1 of 4 123 ... LastLast
Results 1 to 10 of 40

Thread: How to fix XP when the boot files are missing

  1. #1
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

    How to fix Windows when the boot files are missing

    (For Vista or Windows 7 see Post 4 )

    This is a follow up on Herman's post on how to boot XP from a logical partion. His post is not only relevant if XP is on a logical partition, it also applies whenever the boot files for XP are missing. Let me summarize and refine his method

    Step 1) Boot into Ubuntu and mount the XP partition.

    Step 2) Download the attached file Archive.tar.gz. Extract the three files boot.ini , NTLDR and NTDETECT.COM to (the root of) the XP partition.

    Step 3) Edit "boot.ini". The number in ``partition(1)'' needs to be changed to the correct number for your XP partition. Windows starts counting at 1 and counts partitions in the order of the partition table (so far that's the same way linux counts) BUT skips over extended partitions and empty partitions.


    If XP is on a logical partition:

    Step 4) Do NOT use ``makeactive'' in menu.lst.

    Step 5) Use testdisk to rebuild the boot sector.


    Remarks:
    I) In theory one should be able to replace Step 3) by "bootcfg /rebuild" from the Windows Recovery Console. But this did not work out for me. bootcfg did not detect XP, probably since it was on a logical partition.

    II) Step 5) seems to be unnecessary in some cases.


    Detailed Instructions:


    Step 1) Mount your windows partition in Linux


    Code:
    sudo mkdir /Win
    sudo mount /dev/sda5 /Win    
    ls /Win
    (here /dev/sda5 must be replaced by the device name of your Windows partition. Use "sudo fdisk -l" to determine the device name)

    The last command lists all the files in the System directory of your Windows Partition. Look for the files "boot.ini", "NTLDR" and "NTDETECT.COM". If you already have these files, skip Step 2.


    Step 2) Get the boot files and copy them to your Windows partition


    Download this file: http://ubuntuforums.org/attachment.p...6&d=1212690573
    and save it to your home folder (/home/your_username). Then


    Code:
    cd /Win
    sudo tar -xvzf /home/your_username/Archive.tar.gz
    ls /Win
    Make sure you now have the files "boot.ini", "NTLDR" and "NTDETECT.COM"


    Step 3 Edit boot.ini

    Code:
    sudo nano /Win/boot.ini      (don't use "gedit", since it does
                                        not handle dos files correctly )
    Change all "partition(1)" to "partition(3)" (there are two of them) Do not change anything else. Here "3" must be replaced by the correct number for your XP partition. See this post for some examples.

    Save the the file.


    Step 4 Add XP to the Grub menu


    If you are using Grub 2

    Code:
     sudo update-grub
    (if that does not work, try "sudo grub-mkconfig -o /boot/grub/grub.cfg)

    If you are using Legacy Grub

    Code:
    gksudo gedit /boot/grub/menu.lst
    Use

    title XP
    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. So if Windows is /dev/sda5, then the second number is 4.
    The "hd" is always "hd", even if the device name contains "sd".
    If Windows is not on the boot drive, you need to add "map" lines:

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



    Save the file and reboot. Sometimes this does not work right away and you have to do the fifth step.

    Step 5: Rebuild the Boot sector of the Windows partition.

    Install and run "testdisk:

    Code:
    sudo apt-get install testdisk
    
    sudo testdisk  /dev/sda
    (Replace /dev/sda by device name of the XP partition without the number)

    Press "enter" to "proceed"
    Press "enter" to select "intel"
    Use the "down arrow" and "enter" to select "advanced"
    Use the down arrrow to select the "XP" 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:
    Use the "right arrow" key and "enter" to select "write". This will write a modified boot sector to the Windows partition.
    Press q a few times to quit testdisk.

    Reboot.

    ( You can delete "Archive.tar.gz" at any time, but I would wait until you successfully booted into XP)

    If you do not have a working internet connection in Ubuntu

    In Step 2: Download Archive.tar.gz on a different computer and use a flash drive to transfer it to your Ubuntu home folder.

    In Step 5: Download the testdisk-6.10.linux26.tar.bz2 package on a different computer and use a flash drive to transfer it to your Ubuntu home folder. Then in a terminal

    Code:
    cd 
    
    tar xvf testdisk-6.10.linux26.tar.bz2
    
    sudo testdisk-6.10/linux/testdisk_static /dev/sda
    (Replace /dev/sda by device name of the XP partition without the number)

    Press "Enter" to "proceed" and continue as in Step 5.



    Windows 2000

    This tutorial also works for Window 2000 with one modification:

    Each occurrence of "\Windows" in boot.ini must be replaced by "\WINNT"


    This thread successfully used the method and contains some more information.
    Attached Files Attached Files
    Last edited by meierfra.; February 23rd, 2010 at 04:45 AM. Reason: Included instructions for Grub 2

  2. #2
    Join Date
    Feb 2008
    Location
    US
    Beans
    2,782
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: How to fix XP when the boot files are missing

    that should be it. Post if it fails other than that you should be all set.
    EDIT: sorry I read the post a little too quickly a little too late at night and took it more as a question. What was the purpose of splitting the thread?
    Last edited by tamoneya; May 31st, 2008 at 05:47 AM.
    Desktop: Q6600 OC: 343 x 9, 4 GB RAM, 8600 GTS Twinview (22",17"), 1.5 TB RAID 5
    Laptop: Lenovo T61 T7300 @ 2 GHz, 2GB RAM, Nvidia 140M Quadro, 160 GB harddrive
    Remember to mark posts as [SOLVED] when your problem is resolved

  3. #3
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: How to fix XP when the boot files are missing

    and took it more as a question.
    I rephrased the first sentence to avoid this confusion.


    What was the purpose of splitting the thread?
    The original post of Herman appeared hidden in a long thread about Grub error 17. But my post has absolutely nothing to do with "Grub error 17"
    Last edited by meierfra.; June 4th, 2008 at 04:37 AM.

  4. #4
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    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 your operating system under "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.

    This link contains picture of the various screens: http://www.bleepingcomputer.com/tuto...torial148.html


    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:
    bootsect  /nt60  C:
    If you get a unknown command message try

    Code:
    E:\boot\bootsect.exe /nt60  C:
    instead. Although the actually path for "bootsect.exe" might depend on the CD/DVD you are using.


    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.; February 13th, 2010 at 09:01 AM. Reason: Added instruction for Grub2

  5. #5
    Join Date
    Mar 2008
    Location
    California, USA
    Beans
    8,111

    Re: How to fix XP when the boot files are missing

    Meierfra, is it necessary to use "rootnoverify" instead of "root" in the Grub's menu.lst for the Vista entry? Usually you can use just "root" for Win XP/Vista, which actually I find a bit confusing, because NTFS is not a supported file system with Grub; thus I would think "rootnoverify" would always be necessary.

    Also, just a small thing, but is:
    (Replace /dev/sda by device name of the XP partition without the trailing number)
    from step 5 a typo? Shouldn't that be Vista instead of XP?

  6. #6
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: How to fix XP when the boot files are missing

    Meierfra, is it necessary to use "rootnoverify" instead of "root" in the Grub's menu.lst for the Vista entry? Usually you can use just "root" for Win XP/Vista, which actually I find a bit confusing, because NTFS is not a supported file system with Grub; thus I would think "rootnoverify" would always be necessary.
    In my experience "root" works in most cases, but sometimes it does not. And "rootnoverify" seems to always work. Grub cannot read the files on a "NTFS" partition, but "root" only mounts a partition without actually reading any of the files.


    Shouldn't that be Vista instead of XP?
    Yes, I fixed it. Thanks.
    Last edited by meierfra.; October 14th, 2008 at 06:17 PM.

  7. #7
    Join Date
    May 2007
    Location
    San Francisco, California
    Beans
    5,857
    Distro
    Ubuntu Development Release

    Re: How to fix XP when the boot files are missing

    Nice tutorial, good information in here.

  8. #8
    Join Date
    Mar 2008
    Location
    California, USA
    Beans
    8,111

    Re: How to fix XP when the boot files are missing

    One other question, meierfra: when XP/Vista are in a logical partition, if anything happens to the XP/Vista logical partition and the user needs to do a "Windows repair" or similar from the XP/Vista Install/Recovery CD, is it possible? I was under the impression that XP/Vista will not allow themselves to be installed to a logical partition (you have to manually move them there), and thus they also won't allow themselves to be repaired if they are in a logical partition. Any thoughts about this?
    Last edited by caljohnsmith; September 7th, 2008 at 05:50 PM.

  9. #9
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: How to fix XP when the boot files are missing

    if anything happens to the XP/Vista logical partition and the user needs to do a "Windows repair" or similar from the XP/Vista Install/Recovery CD, is it possible?
    Some of the functions of the Recovery CD's seem to work, others do not. I was able to run "fixboot" from the Windows CD, but "bootcfg /rebuild" did not work. Also "bcdedit" from the Vista CD did work, but "autorepair" did not.


    I was under the impression that XP/Vista will not allow themselves to be installed to a logical partition (you have to manually move them there),
    This is not quite true. You can install XP/Vista on a logical partition, as long as you have some primary FAT or NTFS partition. Windows will put the boot files onto this primary partition. Windows calls this partition the System partition. To boot Windows from Grub, you have to use "root (hdX,Y)" where "(hdX,Y)" is the System partition. (There are various threads where people are unable to boot Windows, because they do not realize that the boot files are on some partition, which seem to have nothing to do with the Windows OS)

    I have a dedicated primary Grub Partition in FAT32 format. So I'm able to used the Grub Partition to install XP/Vista on logical partitions.

  10. #10
    Join Date
    Mar 2008
    Location
    California, USA
    Beans
    8,111

    Re: How to fix XP when the boot files are missing

    Quote Originally Posted by meierfra. View Post
    You can install XP/Vista on a logical partition, as long as you have some primary FAT or NTFS partition. Windows will put the boot files onto this primary partition. Windows calls this partition the System partition. To boot Windows from Grub, you have to use "root (hdX,Y)" where "(hdX,Y)" is the System partition. (There are various threads where people are unable to boot Windows, because they do not realize that the boot files are on some partition, which seem to have nothing to do with the Windows OS)
    So if the user has all his boot files on a primary partition, but his main Windows install is on a logical partition, is it the boot.ini file that then points to the logical partition? I.e. does "partition(X)" in boot.ini need to be the logical partition I would presume and not the primary partition where the boot.ini is located?

Page 1 of 4 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •