Today I saw a thread in ubuntuforums said someone lost ntldr file after ubuntu installed.And this tutorial shows how to fix Windows when you lost boot.ini,ntldr files.You do not need a Windows Live-CD,just need to boot into Ubuntu.

1.Mount the Windows partition.

Use this command to determine the device name of Windows,always Windows installed in first partition of first hard disk.

sudo fdisk -l

Create a mount point and mount the partition:

sudo mkdir /media/WinXP

sudo mount /dev/sda1 /media/WinXP -t ntfs -o rw

Change /dev/sda1 to the device name.

2.Download archivetar,and extract to the root directory of Windows partition.

Use following command to extract the package.

cd /media/WinXP

sudo tar -xzvf ~/Archive.tar.gz

And run this command,you should see the three files:boot.ini,NTLDR,NDETECT.COM

3.Edit boot.ini(if your Windows partition is sda1,skip this step).

sudo nano /media/WinXP/boot.ini

Change all “partition(1)” to “partition(n)”,for example,your Windows partition is dev/sda5,change all “partition(1)” to “partition(5)”.Ctrl+O and Enter to save file,the Ctrl+X to close.

4.Edit /boot/grub/menu.lst

gksudo gedit /boot/grub/menu.lst

Find this section:

title        Microsoft Windows XP Professional
rootnoverify    (hd0,0)
chainloader    +1

and delete the line “makeactive”,if there’s no this section,add it to the end without “makeactive”.(hd0,0) stands for the first partition of the first hard drives.

5.Rebuild Boot sector.

Download the

Run following commands:

tar xvf testdisk-6.10.linux26.tar.bz2
sudo testdisk-6.10/linux/testdisk_static /dev/sda

Enlarge the terminal window and:

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 “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.
Then just follow the instruction on the screen to save to quit testdisk.