# Ubuntu 10.04 upgrade - Cant dual boot Windows 7



## 05026652 (May 5, 2010)

Hey there,

Well certainly a rookie mistake made on my part here. I have a dual boot machine with Ubuntu and Win 7 installed. Yesterday I had a little play with my ubuntu install and upgraded to 10.04 Lucid Lynx. All was well until I went to boot into windows. When I select this option, the screen goes black, as ready to load then a little cursor is found in the top right hand corner flashing constantly. It looks similiar boot style to the Ubuntu OS.

Any idea what has gone on?

I can access my two HD drives in Ubuntu so data loss isnt a problem.

Any ideas would be great. If you want any more information let me know

Thanks


----------



## saikee (Jun 11, 2004)

Post here Ubuntu's /boot/grub/grub.cfg and the output of 

```
fdisk -l
```
Have you alered the disk order recently and confirm which one boots first?


----------



## 05026652 (May 5, 2010)

*Ubuntu boot\grub\grub.cfg*


```
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
  set saved_entry=${prev_saved_entry}
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z ${boot_once} ]; then
    saved_entry=${chosen}
    save_env saved_entry
  fi
}

function recordfail {
  set recordfail=1
  if [ -n ${have_grubenv} ]; then if [ -z ${boot_once} ]; then save_env recordfail; fi; fi
}
insmod ext2
set root='(hd0,5)'
search --no-floppy --fs-uuid --set bf80e28e-d819-46d9-aea1-6b164a98c5e9
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=640x480
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
insmod ext2
set root='(hd0,5)'
search --no-floppy --fs-uuid --set bf80e28e-d819-46d9-aea1-6b164a98c5e9
set locale_dir=($root)/boot/grub/locale
set lang=en
insmod gettext
if [ ${recordfail} = 1 ]; then
  set timeout=-1
else
  set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu, with Linux 2.6.32-21-generic' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod ext2
    set root='(hd0,5)'
    search --no-floppy --fs-uuid --set bf80e28e-d819-46d9-aea1-6b164a98c5e9
    linux    /boot/vmlinuz-2.6.32-21-generic root=UUID=bf80e28e-d819-46d9-aea1-6b164a98c5e9 ro   quiet splash
    initrd    /boot/initrd.img-2.6.32-21-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-21-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod ext2
    set root='(hd0,5)'
    search --no-floppy --fs-uuid --set bf80e28e-d819-46d9-aea1-6b164a98c5e9
    echo    'Loading Linux 2.6.32-21-generic ...'
    linux    /boot/vmlinuz-2.6.32-21-generic root=UUID=bf80e28e-d819-46d9-aea1-6b164a98c5e9 ro single 
    echo    'Loading initial ramdisk ...'
    initrd    /boot/initrd.img-2.6.32-21-generic
}
menuentry 'Ubuntu, with Linux 2.6.31-20-generic' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod ext2
    set root='(hd0,5)'
    search --no-floppy --fs-uuid --set bf80e28e-d819-46d9-aea1-6b164a98c5e9
    linux    /boot/vmlinuz-2.6.31-20-generic root=UUID=bf80e28e-d819-46d9-aea1-6b164a98c5e9 ro   quiet splash
    initrd    /boot/initrd.img-2.6.31-20-generic
}
menuentry 'Ubuntu, with Linux 2.6.31-20-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod ext2
    set root='(hd0,5)'
    search --no-floppy --fs-uuid --set bf80e28e-d819-46d9-aea1-6b164a98c5e9
    echo    'Loading Linux 2.6.31-20-generic ...'
    linux    /boot/vmlinuz-2.6.31-20-generic root=UUID=bf80e28e-d819-46d9-aea1-6b164a98c5e9 ro single 
    echo    'Loading initial ramdisk ...'
    initrd    /boot/initrd.img-2.6.31-20-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
    insmod ext2
    set root='(hd0,5)'
    search --no-floppy --fs-uuid --set bf80e28e-d819-46d9-aea1-6b164a98c5e9
    linux16    /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
    insmod ext2
    set root='(hd0,5)'
    search --no-floppy --fs-uuid --set bf80e28e-d819-46d9-aea1-6b164a98c5e9
    linux16    /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Dell Utility Partition (on /dev/sda1)" {
    insmod fat
    set root='(hd0,1)'
    search --no-floppy --fs-uuid --set 07d6-0c14
    drivemap -s (hd0) ${root}
    chainloader +1
}
menuentry "Windows 7 (loader) (on /dev/sda2)" {
    insmod ntfs
    set root='(hd0,2)'
    search --no-floppy --fs-uuid --set c0b05f46b05f41d8
    chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###
```
I tried using the fdisk -l in terminal but nothing happened? Sorry I am a newb at the ubuntu etc.

I haven't altered the disk order, and on boot screen Ubuntu boots first.

I hope that made sense, thanks for the reply .


----------



## saikee (Jun 11, 2004)

This entry tells us your Ubuntu is in the 5th partition of the first disk (hd0)

```
menuentry '[COLOR="Purple"]Ubuntu, with Linux 2.6.32-21-generic[/COLOR]' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod ext2
[COLOR="Purple"]    set root='(hd0,5)'[/COLOR]
    search --no-floppy --fs-uuid --set bf80e28e-d819-46d9-aea1-6b164a98c5e9
    linux    /boot/vmlinuz-2.6.32-21-generic root=UUID=bf80e28e-d819-46d9-aea1-6b164a98c5e9 ro   quiet splash
    initrd    /boot/initrd.img-2.6.32-21-generic
}
```
These two entries tells us that you have a manufacturer driver/utility partition in the 1st partition and a Win7 on the 2nd partition of the same hard disk (hd0)

```
menuentry "[COLOR="Blue"]Dell Utility Partition[/COLOR] (on /dev/sda1)" {
    insmod fat
[COLOR="Blue"]    set root='(hd0,1)'[/COLOR]
    search --no-floppy --fs-uuid --set 07d6-0c14
    drivemap -s (hd0) ${root}
    chainloader +1
}
menuentry "[COLOR="Red"]Windows 7[/COLOR] (loader) (on /dev/sda2)" {
    insmod ntfs
[COLOR="Red"]    set root='(hd0,2)'[/COLOR]
    search --no-floppy --fs-uuid --set c0b05f46b05f41d8
    chainloader +1
}
```
Only your "fdisk -l" output can confirm if the above information is correct, as you have insisted that you have two hard 
drives whereas the bootloader thinks everything in one disk!

In Ubuntu, or any other Linux, operating a system-related command requires root privilege, which corresponds to the Admin right of Win7, and you need to be in root (or run as Administrator). To do this in Ubuntu you type

```
sudo su
```
 and supply the normal user password.

You will find "fdisk -l" responding differently.

In your fdisk -l output the Win7 should boot if it is in /dev/sda2, has a partition type No. 7 and has a "*" indicating it has been marked active.


----------



## 05026652 (May 5, 2010)

*Fdisk -l Output*


```
Disk /dev/sda: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe686f016

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1           8       64228+  de  Dell Utility
/dev/sda2   *           9       15341   123162322+   7  HPFS/NTFS
/dev/sda3           15342       29787   116037495    f  W95 Ext'd (LBA)
/dev/sda4           29788       30393     4867695   db  CP/M / CTOS / ...
/dev/sda5           15342       29787   116037463+  83  Linux

Disk /dev/sdb: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000081

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb3   *           1       30394   244139773+   7  HPFS/NTFS
```
Thanks


----------



## saikee (Jun 11, 2004)

You have two NTFS partitions. One in /dev/sda2 of about 120Gb and another /dev/sdb3 250Gb in a separate disk. Linux and other systems do not know what their contents are. May be that is why Grub2 has gone to sda2.

Since that doesn't boot so you must have put your MS system in the 250Gb disk.

You can edit /boot/grub/grub.cfg by command

```
nano /boot/grub/grub.cfg
```
altering the root statement from 

```
set root='(hd0,[COLOR="Blue"]2[/COLOR])'
```
to 

```
set root='(hd1,[COLOR="Red"]3[/COLOR])'
```
You can try this out manually in the following steps
when you see the Grub boot screen don't boot anything but just press the "c" key into a Grub prompt and type these commands

```
set root=(hd1,3)
chainloader +1
boot
```
If it works then proceed to amend the grub.cfg as suggested.

In the above you fire up the Windows manually first to test the Grub2 commands.


----------



## 05026652 (May 5, 2010)

thanks mate ill give it a whirl now


----------



## 05026652 (May 5, 2010)

No such luck, I tried it out manually first and it went straight to the screen as I described earlier on?


----------



## saikee (Jun 11, 2004)

Can you tell us where is your Windowa installation?

Is it in the first disk with Ubuntu as sda2? or in the second disk sdb3. You must have done some manipulations with the second hard disk to get it recognised as sdb3 where there isn't sdb1 and sdb2 there.

If another partition has been created or found before your Windows in the booting queue then your Windows will not be able to boot up as a "c" drive. In such case it will not boot because the installed drive letter cannot be adhered to. In your case sda2 is the first partition recognised by a MS system and sdb3 is the 2nd in the queue. You need to tell us what the two are.

Did you have Grub1 before? If you did then the original booting instructions will be in /boot/grub/menu.lst. Post it here. Grub1 can swap the disk order on the fly but I haven't gone deep enough how this is done in Grub2 which you are using.

Haven't tried it myself but the internet information suggests that the change the disk order for booting a MS Windows installed in (hd0) but subsequently moved to (hd1) would be

```
drivemap hd0 hd1
drivemap hd1 hd0
```
to be issued before the "boot" command.


----------



## 05026652 (May 5, 2010)

I have two 250GB drives, now when I originally installed Ubuntu (about December time) i'm pretty sure that I partioned the first hard drive, so that I can run Win 7 and Ubuntu on it. The second drive was used primarily to store my data, music, uni work etc on. 

I have mounted both drives just for convenience, the drive that has Win 7 on has 117GB on it, the other has 232GB confirming that the two OS were installed on the first hard drive.

I dont think Grub1 was used I cannot find the menu.lst file in the location provided.

Does that help?


----------



## saikee (Jun 11, 2004)

I would suggest to boot the Win7 manually with these commands at a Grub2 prompt

```
set root=(hd0,2)
chainloader +1
boot
```
I am convinced your sdb3 is just a data partition and your 1st disk in the Bios is sda. There is nothing strange about your system.

If the above fail you might have to recourse to the Win7 installation DVD and getting involved with bcdedit.ext, bootsect.exe and bootrec.exe.


----------



## 05026652 (May 5, 2010)

Ok so I have given that I try....still no luck. What needs to be done regarding the Win 7 DVD and bcedit.ext etc.??


----------



## saikee (Jun 11, 2004)

Basically you have to restore Win7 boot loader's MBR. That will temporarily disable your Ubuntu which you need the installation CD to restore Grub2 ultimately.

To restore Win7 MBR you boot up the W7 DVD, opt for repair and select Command prompt. The command to restore W7 MBR is 

```
bootrec /fixmbr
```
Depending on how your W7 current state the bootsect.exe can be used to restore its boot sector. Bcdedit.exe is used to edit the booting menu. The boot.rec can be used to rebuild the booting menu from scratch.


----------



## 05026652 (May 5, 2010)

Alright mate ill give that a try. Thanks for the help


----------



## omalsa04 (May 12, 2010)

hey guys,

I had exactly the same problem, and after a little bit of googling I came up with this fix:
https://bugs.launchpad.net/ubuntu/+s...b2/+bug/576724

worked perfectly XD

Sam


----------



## omalsa04 (May 12, 2010)

woops sorry. That's the bug report.

This is the fix:
http://sourceforge.net/apps/mediawiki/bootinfoscript/index.php?title=Boot_Problems:Boot_Sector

Where is the "Edit" button in this forum? XD


----------



## saikee (Jun 11, 2004)

The link suggests some Linux installers have put Grub2 in the Windows partition instead of a Linux or "data only" partition. This is clearly a serious fault as Grub2 cannot read a ntfs partition.

I would fix the problem using Windows Xp CD or Vista DVD which is faster.


----------



## omalsa04 (May 12, 2010)

it's because the grub user interface in the upgrade is really unfriendly to new users.

Use the second link I sent to fix your problem, it's a much friendlier solution to new users (using the testdisk program). Although saikee's method is the proper way to do it. XD


----------



## 05026652 (May 5, 2010)

Hey guys thanks for the repsonse.

Well I have tried using the Win 7 CD and fixboot etc, that didnt acheive anything, then after reinstalling my ubuntu (is there not an easier way to re-install Grub2) I have given it a rest with still no luck.

*Omalsa* - Thanks for your input, but I have just tried that and unfortunately the tutorial suggests that there is a different problem, because at screen/step 6 it sais _"sixth screen did not have a "BackupBS" tab, it usually means that the original and backup boot sector are identical, and you are probably suffering from a different problem._" Any further suggestions would be appreciated.

Also I have resorted to reinstalling Windows 7 after the fixboot etc had failed but didnt get anywhere with that and still had the blank screen with flashing cursor!

Thanks


----------



## omalsa04 (May 12, 2010)

hey,

you will also not get the BackupBS tag if you chose the wrong partition.
As in, you didn't choose the partition that contained the MBR.

I hope it all goes ok for you! Would hate to lose an Ubuntu user just because of this. =O


----------



## saikee (Jun 11, 2004)

I would suggest you check your boot partition, where the boot loader resides, to make sure it is marked "bootable" otherwise your MS Windows will not boot no matter how hard you try.

I have moved Vista and Win7 many times and it takes only 4 steps.

My system was installed as a D drive so these are what I put in the "c" drive which can be a Dos partition or just a NTFS partition. My C drive can have no operating system inside but it must be marked "active" or "bootable". If your MS Windows is booted from a "C" drive then it will have the boot loader inside and the "C" drive must be marked bootable.

(1) place bootmgr inside C:. The bootmgr is obtainable from Win7 or Vista installation DVD
(2) fix the MBR by command (boot up Vista/Win7 installation DVD and opt for repair then command prompt)

```
bootrec /fixmbr
```
(3) fix Win7/Vista boot sector by command

```
bootsect /nt60 c:
```
(4) rebuild the BCD by command

```
bootrec /rebuildbcd
```
If you are fixing a xp then use 
(1) place NTLDR, boot.ini and NTDETECT.COM inside C:. These are obtainable from XP installation CD. The files have to be hidden eventually by editing their attributes
(2) fix the MBR by command (boot up Xp installation CD and opt for repair then Recovery Console)

```
fixmbr
```
(3) fix Xp boot sector by command

```
fixboot
```
 which is equivalent to booting up a Vista/Win7 DVD and command

```
bootsect /nt52 c:
```


----------



## 05026652 (May 5, 2010)

omalsa04 said:


> hey,
> 
> you will also not get the BackupBS tag if you chose the wrong partition.
> As in, you didn't choose the partition that contained the MBR.
> ...


Im pretty sure its the correct partition . Despite the problem you have gained an Ubuntu user so to speak....it certainily the way forward.

*saikee* -Thanks again for extensive tech help, before I do this do you know of a easier way to re-install Grub2 without having to Reinstall Ubuntu and start from scratch?

Thanks


----------



## TerryNet (Mar 23, 2005)

You have now (re-)installed Windows 7 and can boot into that? If so, try How to restore Grub 2 after reinstalling Windows XP/Vista/Win7 (unless *saikee *suggests something different).


----------



## saikee (Jun 11, 2004)

As a rule everyl boot loader can be restore without the need of a re-installation. The Linux boot loaders are among the easiest to be reinstated.

The best Grub2 guide I came across is the one prepared by a member of Kubuntu forum. That guide is easy because all one needs is a Ubuntu Live CD.

Here is a reprint from its Page 33


> Live CD rescue: Re-install GRUB 2
> sudo mkdir /media/sda2 /media/dev
> sudo mount /dev/sda2 /media/sda2
> sudo mount --bind /dev /media/dev
> ...


This method works because you are using a Ubuntu Live CD which has the grub-install command readily available. This is more reliable than my usual "change root" approach in my just booting tips.

Here is my own method------------------------------

I has a floppy drive and so to me the easiest way is to boot up Grub1 that can read a partition Ext4 or a Grub2. Most Grub1 in new distros have been doctored to read Ext4 partitions.

Ubuntu can be fired up in any Grub prompt by simple commands, say it is in the 2nd partition of the first disk

```
root (hd0,1)
kernel /vmlinuz ro root=/dev/sda2
initrd /initrd.img
boot
```
It is a standard many distros provide symbolic links to the kernel and initrd files and dump a copy in the root directory /. So it is pretty easy to boot up a modern Linux manually with Grub.

For Grub2 the equivalent instructions to fire up a Ubuntu would be

```
set root=(hd0,2)
configfile /boot/grub/grub.cfg
```
The Ubuntu has the configuration file grub.cfg and so one can uses the configfile to load it. Grub1 can load a configuration file of Grub2 because it can't under the new syntax.

Once Ubuntu up and running just do a grub-install to restore it to the MBR

```
sudo grub-install /dev/sda
```


----------



## 05026652 (May 5, 2010)

Ahh pain in the butt - Right I have tried the above method a few times *saikee, *I had followed the first set of instructions regarding win 7, when I rebooted it again nothing happened. I reinstalled Grub 2 and when I went to click Windows in the corner where the cursor mark was, there was the word "ressed", which I have no idea what it could be etc.

Maybe im doing something wrong, I hope not coz I had followed the instructions to every word. Any other ideas guys??

If not I might just wipe that partition and install W7 from fresh again, as I have backed up the important docs (mainly uni work). What you reckon?

Thanks


----------



## saikee (Jun 11, 2004)

When you restore the Win7 boot loader you should be in command prompt and able to see all your files. I suppose this is the case.

Also in Linux you can mount the Win7 partition and able to work with your data using Linux software.

The above are just pointers to establish if the partition is good and the content can be read and written.

When you select Win7 in Grub2 you should see it as a choice stating what the line menuentry states and that should be 

```
menuentry "[B][COLOR="Red"]Windows 7 (loader) (on /dev/sda2)[/COLOR][/B]"
```
. Is this correct?

You will need a re-install if you have damaged the Win7 partition inadventently. The method of restoring Win7 is the M$ official method using a Win7/Vista installation DVD.


----------



## 05026652 (May 5, 2010)

Yeah the above two pointers are true...that why I haven't been panicking too much, because I know I can access/backup my files via Linux.

Yes, at the Grub2 menu that is what appears.

When I select it it just goes to a blank screen with the work "ressed" presented.


----------



## saikee (Jun 11, 2004)

Grub cannot boot a MS Windows. What Grub does is to boot Win7's boot loader bootmgr and hand over the control to it. It is up to bootmgr that fires up Win7.

In a pure MS system booting procedure the "bootsect.exe /nt60" restores Win7 boot sector and "bootrec.exe /fixmbr" restore the Win7 MBR. The "bootrec.exe /rebuildbcd" will find every Vista and Win7 in the hard disks and compile a menu for booting. All these activities are executable a Command Prompt with a Vista/Win7 installation DVD.

Therefore if you do the above three steps the Bios can then put Win7's MBR in the memoray. The MBR will check the 4 primaries and boots up the boots sector of the one that has been marked active or bootable. This has been confirmed by Post #5 (look for the * sign as it indicates that partition bootable). The boot sector code then passes the control to bootmgr. 

If the above scheme fails then your Win7 has been damaged to the point it can no longer be booted. That is why I suggested a re-installation.


----------

