# A Question on Dual Boot Problem(Ubuntu/Windows7)



## sunny_sigara (May 24, 2010)

I have Windows XP & Ubuntu 10.04 in my machine.

I have installed XP on C: drive(sda1),& ubuntu( root partition)on D: drive(sda5).I didnt create a separate /boot  partition during ubuntu installation & the drive letter for swap partition is N:  as seen from XP Disk Manager).

When i run "*sudo fdisk -l*" in ubuntu it gives following output-
-----------------------------------------------------------------------------------
Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 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: 0x7a3cfdca

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1275    10241406    7  HPFS/NTFS
/dev/sda2            1276       30401   233954564+   f  W95 Ext'd (LBA)
/dev/sda5            1276        3302    16281846   83  Linux
/dev/sda6            3303        3570     2152678+  82  Linux swap / Solaris
/dev/sda7            3571        4207     5116671    7  HPFS/NTFS
/dev/sda8            4208        6756    20474811    7  HPFS/NTFS
/dev/sda9            6757        7648     7164958+   7  HPFS/NTFS
/dev/sda10           7649        8922    10233373+   7  HPFS/NTFS
/dev/sda11           8923       11471    20474811    7  HPFS/NTFS
/dev/sda12          11472       17845    51199123+   7  HPFS/NTFS
/dev/sda13          17846       23581    46074388+   7  HPFS/NTFS
/dev/sda14          23582       29062    44026101    7  HPFS/NTFS
/dev/sda15          29063       30401    10755486    7  HPFS/NTFS
----------------------------------------------------------------------------------

when i run " sudo blkid" it gives me following output:
--------------------------------------------------------------------------------
/dev/sda1: LABEL="WIN XP" UUID="40EA5D8CEA5D7EDA" TYPE="ntfs" 
/dev/sda5: UUID="66617334-1c9d-48d9-a2be-141a30d978c7" TYPE="ext3" 
/dev/sda6: UUID="69b6b265-3958-4a75-9cf0-0749f1464ff8" TYPE="swap" 
/dev/sda7: LABEL="TEMP" UUID="01CA22AC9F071040" TYPE="ntfs" 
/dev/sda8: LABEL="TOOLS" UUID="01CA22ACA12F4770" TYPE="ntfs" 
/dev/sda9: LABEL="DOCUMENTS" UUID="01CA22ACA3E40730" TYPE="ntfs" 
/dev/sda10: LABEL="Downloads" UUID="01CA22ACA5E618C0" TYPE="ntfs" 
/dev/sda11: LABEL="MUSIC & MOVIES" UUID="01CA22ACA86B3D00" TYPE="ntfs" 
/dev/sda12: LABEL="GAMES (Action)" UUID="01CA22ACAB355980" TYPE="ntfs" 
/dev/sda13: LABEL="GAMES (Racing)" UUID="01CA22AD2F34DA80" TYPE="ntfs" 
/dev/sda14: LABEL="GAMES (Strategy)" UUID="01CA22AD321DC9A0" TYPE="ntfs" 
/dev/sda15: LABEL="LINUX" UUID="01CA22AD353B3640" TYPE="ntfs" 
-------------------------------------------------------------------------------------


I* want to install Windows 7 on my C: partition.* For that reason, to increase the space on my primary partition, i am going to merge C: drive(sda1) & L: Drive( the entire L drive as a folder of c ). My L: drive(sda14) is completely empty.

Now as we know installing windows 7 will rewrite the boot loader, my question is- 

*How to restore default grub boot loader so that I can select the desired OS from the boot menu without re-installing Ubuntu?


*plz help.

My current 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 66617334-1c9d-48d9-a2be-141a30d978c7
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 66617334-1c9d-48d9-a2be-141a30d978c7
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 66617334-1c9d-48d9-a2be-141a30d978c7
    linux    /boot/vmlinuz-2.6.32-21-generic root=UUID=66617334-1c9d-48d9-a2be-141a30d978c7 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 66617334-1c9d-48d9-a2be-141a30d978c7
    echo    'Loading Linux 2.6.32-21-generic ...'
    linux    /boot/vmlinuz-2.6.32-21-generic root=UUID=66617334-1c9d-48d9-a2be-141a30d978c7 ro single 
    echo    'Loading initial ramdisk ...'
    initrd    /boot/initrd.img-2.6.32-21-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 66617334-1c9d-48d9-a2be-141a30d978c7
    linux16    /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
    insmod ext2
    set root='(hd0,5)'
    search --no-floppy --fs-uuid --set 66617334-1c9d-48d9-a2be-141a30d978c7
    linux16    /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows NT/2000/XP (on /dev/sda1)" {
    insmod ntfs
    set root='(hd0,1)'
    search --no-floppy --fs-uuid --set 40ea5d8cea5d7eda
    drivemap -s (hd0) ${root}
    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 ###
------------------------------------------------------------------------------------


----------



## celldweller1591 (May 24, 2010)

win7 will probably wipe out grub. So boot from livecd.In the desktop, open terminal and type
_sudo grub_
 This will set it to grub mode
_find /boot/grub/stage1_
 This will locate your boot partition. Since we know that your root is hd(0,5),we can ignore it.
After that type in :
_root (hd0,5)_
_setup (hd0)_
_quit_
 Reboot your system. for details see here 
then run 
_sudo apt-get update grub_
and your win7 bootloader will be detected by grub and you will get an option to select b/w ubuntu and win7 at grub menu. Try it


----------



## sunny_sigara (May 24, 2010)

Thanks for the info...i will definitely try it.


----------



## ico (May 28, 2010)

*help.ubuntu.com/community/Grub2#Reinstalling GRUB 2


----------



## Flake (May 28, 2010)

You are using Ubuntu 10.4 and it has GRUB2 by default. 
After installing Windows OS, boot up from Ubuntu 10.04 LiveCD, open Terminal and execute this

```
sudo mount /dev/sda5 /mnt
sudo grub-install --root-directory=/mnt /dev/sda  
sudo umount /mnt
```
That's it ! It will re-install GRUB.


----------

