Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I know a lot of people are having problems similar to this one, but I don't think this is a duplicate. My situation is a bit different and none of the solutions that are working for other people have worked for me.

I have two hard drives, one with just one primary partition (sdb) and one with several partitions (sda). My fdisk -l looks like this:

Disk /dev/sdb: 750.2 GB, 750156374016 bytes
16 heads, 63 sectors/track, 1453521 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x316f8b1c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          63  1465145135   732572536+   7  HPFS/NTFS/exFAT

Disk /dev/sda: 320.1 GB, 320072933376 bytes
210 heads, 6 sectors/track, 496144 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xeb0feb0f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           6   206847899   103423947    7  HPFS/NTFS/exFAT
/dev/sda2       206847998   625141759   209146881    5  Extended
/dev/sda5       206848000   616753151   204952576   83  Linux
/dev/sda6       616755200   625141759     4193280   82  Linux swap / Solaris

I have Ubuntu 11.10 installed on sda5 and windows 7 installed on sdb1 (I'm not sure what's on the primary partition /dev/sda1 -- some old operating system I don't care about). I installed Windows first, then installed Ubuntu. I'm using grub as my boot loader, and I'm able to boot to Ubuntu (and using it now) but at first update-grub2 didn't even see Windows 7. After searching online, I found a common solution to this was to create an /etc/grub.d/11_Windows init script containing:

#! /bin/sh -e
echo Adding Windows >&2
cat << EOF
menuentry "Windows 7″ {
    set root=(hd1,1)
    chainloader +1
}

Here I set root to (hd1,1) to match sdb1. This added Windows 7 to the grub menu, but if you select it, it just shows a blank screen and hangs (it does not boot into Windows 7). I've tried a number of solutions given to people having similar (but not identical) problems as mine and can't get anything to work.

Can anyone help me?

Here is the output of Boot Info Script:

          Boot Info Script 0.60    from 17 May 2011


============================= Boot Info Summary: ===============================

 => Grub2 (v1.99) is installed in the MBR of /dev/sda and looks at sector 
    535689840 of the same hard drive for core.img. core.img is at this 
    location and looks for ?? on this drive.
 => Windows is installed in the MBR of /dev/sdb.

sda1: __________________________________________________________________________

    File system:       
    Boot sector type:  Grub Legacy
    Boot sector info:   Grub Legacy (v) is installed in the boot sector of 
               sda1 and looks at sector 509109856 of the same hard 
               drive for the stage2 file, but no stage2 files can be 
               found at this location.
    Mounting failed:   mount: unknown filesystem type ''

sda2: __________________________________________________________________________

    File system:       Extended Partition
    Boot sector type:  Unknown
    Boot sector info:  

sda5: __________________________________________________________________________

    File system:       ext4
    Boot sector type:  -
    Boot sector info:  
    Operating System:  Ubuntu 11.10
    Boot files:        /boot/grub/grub.cfg /etc/fstab /boot/grub/core.img

sda6: __________________________________________________________________________

    File system:       swap
    Boot sector type:  -
    Boot sector info:  

sdb1: __________________________________________________________________________

    File system:       ntfs
    Boot sector type:  Windows XP
    Boot sector info:   No errors found in the Boot Parameter Block.
    Operating System:  Windows 7
    Boot files:        /Windows/System32/winload.exe

============================ Drive/Partition Info: =============================

Drive: sda _____________________________________________________________________

Disk /dev/sda: 320.1 GB, 320072933376 bytes
210 heads, 6 sectors/track, 496144 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

Partition  Boot  Start Sector    End Sector  # of Sectors  Id System

/dev/sda1    *              6   206,847,899   206,847,894   7 NTFS / exFAT / HPFS
/dev/sda2         206,847,998   625,141,759   418,293,762   5 Extended
/dev/sda5         206,848,000   616,753,151   409,905,152  83 Linux
/dev/sda6         616,755,200   625,141,759     8,386,560  82 Linux swap / Solaris


Drive: sdb _____________________________________________________________________

Disk /dev/sdb: 750.2 GB, 750156374016 bytes
16 heads, 63 sectors/track, 1453521 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

Partition  Boot  Start Sector    End Sector  # of Sectors  Id System

/dev/sdb1    *             63 1,465,145,135 1,465,145,073   7 NTFS / exFAT / HPFS


"blkid" output: ________________________________________________________________

Device           UUID                                   TYPE       LABEL

/dev/sda5        20d584af-9217-4d71-a822-7663b9530da4   ext4       
/dev/sda6        ce8b7879-9234-4c89-b62f-a09737d1d1cf   swap       
/dev/sdb1        22A4F723A4F6F85D                       ntfs       windows7

================================ Mount points: =================================

Device           Mount_Point              Type       Options

/dev/sda5        /                        ext4       (rw,errors=remount-ro,commit=0)
/dev/sdb1        /media/windows-7         fuseblk    (rw,noexec,nosuid,nodev,allow_other,blksize=4096,default_permissions)


=========================== sda5/boot/grub/grub.cfg: ===========================

--------------------------------------------------------------------------------
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by 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
  set have_grubenv=true
  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
}

function load_video {
  insmod vbe
  insmod vga
  insmod video_bochs
  insmod video_cirrus
}

insmod part_msdos
insmod ext2
set root='(hd0,msdos5)'
search --no-floppy --fs-uuid --set=root 20d584af-9217-4d71-a822-7663b9530da4
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  insmod part_msdos
  insmod ext2
  set root='(hd0,msdos5)'
  search --no-floppy --fs-uuid --set=root 20d584af-9217-4d71-a822-7663b9530da4
  set locale_dir=($root)/boot/grub/locale
  set lang=en_US
  insmod gettext
fi
terminal_output gfxterm
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
if background_color 0,71,115; then
  clear
fi
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
if [ ${recordfail} != 1 ]; then
  if [ -e ${prefix}/gfxblacklist.txt ]; then
    if hwmatch ${prefix}/gfxblacklist.txt 3; then
      if [ ${match} = 0 ]; then
    set linux_gfx_mode=keep
      else
    set linux_gfx_mode=text
      fi
    else
      set linux_gfx_mode=text
    fi
  else
    set linux_gfx_mode=keep
  fi
else
  set linux_gfx_mode=text
fi
export linux_gfx_mode
if [ "$linux_gfx_mode" != "text" ]; then load_video; fi
menuentry 'Ubuntu, with Linux 3.0.0-14-generic' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    set gfxpayload=$linux_gfx_mode
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='(hd0,msdos5)'
    search --no-floppy --fs-uuid --set=root 20d584af-9217-4d71-a822-7663b9530da4
    linux   /boot/vmlinuz-3.0.0-14-generic root=UUID=20d584af-9217-4d71-a822-7663b9530da4 ro   quiet splash vt.handoff=7
    initrd  /boot/initrd.img-3.0.0-14-generic
}
menuentry 'Ubuntu, with Linux 3.0.0-14-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='(hd0,msdos5)'
    search --no-floppy --fs-uuid --set=root 20d584af-9217-4d71-a822-7663b9530da4
    echo    'Loading Linux 3.0.0-14-generic ...'
    linux   /boot/vmlinuz-3.0.0-14-generic root=UUID=20d584af-9217-4d71-a822-7663b9530da4 ro recovery nomodeset 
    echo    'Loading initial ramdisk ...'
    initrd  /boot/initrd.img-3.0.0-14-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/11_Windows ###
menuentry âWindows 7â³ {
    set root=(hd1,1)
    chainloader +1
}
### END /etc/grub.d/11_Windows ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
    insmod part_msdos
    insmod ext2
    set root='(hd0,msdos5)'
    search --no-floppy --fs-uuid --set=root 20d584af-9217-4d71-a822-7663b9530da4
    linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
    insmod part_msdos
    insmod ext2
    set root='(hd0,msdos5)'
    search --no-floppy --fs-uuid --set=root 20d584af-9217-4d71-a822-7663b9530da4
    linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
### 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 ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
--------------------------------------------------------------------------------

=============================== sda5/etc/fstab: ================================

--------------------------------------------------------------------------------
# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/sda5 during installation
UUID=20d584af-9217-4d71-a822-7663b9530da4 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda6 during installation
UUID=ce8b7879-9234-4c89-b62f-a09737d1d1cf none            swap    sw              0       0

/dev/sdb1       /media/windows-7       ntfs-3g      quiet,defaults,locale=en_US.utf8,umask=0,noexec     0 0

--------------------------------------------------------------------------------

=================== sda5: Location of files loaded by Grub: ====================

       GiB - GB             File                                 Fragment(s)

           =                boot/grub/core.img                             1
           =                boot/grub/grub.cfg                             1
           =                boot/initrd.img-3.0.0-14-generic               3
           =                boot/vmlinuz-3.0.0-14-generic                  1
           =                initrd.img                                     3
           =                vmlinuz                                        1

======================== Unknown MBRs/Boot Sectors/etc: ========================

Unknown BootLoader on sda2

00000000  0d d6 82 9e f4 dd 3d 74  1c cd c2 f8 71 11 73 56  |......=t....q.sV|
00000010  e8 03 9d f7 fc 86 9b 37  8d 79 4e 66 ca ac 9a 96  |.......7.yNf....|
00000020  e9 77 46 3f 3b 8c 7e f6  63 f0 d1 4e e3 fc 4a e3  |.wF?;.~.c..N..J.|
00000030  ff 04 79 9c ce 2b 4e 6d  4e 9a 86 d5 f4 c5 2f 9c  |..y..+NmN...../.|
00000040  d6 b5 90 8e 91 29 94 d6  66 0c b8 40 1a 2f 82 6f  |.....)..f..@./.o|
00000050  18 03 f2 ea b8 73 4d e9  2b e8 1a 05 aa 1b 75 b2  |.....sM.+.....u.|
00000060  9e e6 f9 f7 8c 09 bb 97  fd 93 df e7 33 26 da d7  |............3&..|
00000070  20 e4 f1 ad 5d e4 89 31  87 38 cb bc b5 15 e5 dc  | ...]..1.8......|
00000080  fa 80 c3 b7 cb 9a b6 26  a4 29 33 e3 de f7 a4 eb  |.......&.)3.....|
00000090  3c f9 fc 25 79 5f 43 da  0c 65 b8 57 f6 b3 c8 b7  |<..%y_C..e.W....|
000000a0  d2 c6 79 e0 68 cc 43 75  ff ea 87 95 cc 11 f6 da  |..y.h.Cu........|
000000b0  6c 43 76 27 0e fb 3c 71  9e 41 7e 0a 9c 06 e7 74  |lCv'..<q.A~....t|
000000c0  2f bc 3d 7a 74 00 ed 74  3e f4 26 63 73 c4 61 fa  |/.=zt..t>.&cs.a.|
000000d0  04 90 02 d4 c3 5c 77 9d  31 9f 66 ae 70 46 e7 0a  |.....\w.1.f.pF..|
000000e0  03 98 2b 9e c6 5c e5 24  e3 83 7c f3 ac 73 b8 ad  |..+..\.$..|..s..|
000000f0  cc 0f 9a 91 86 2c a4 a1  05 b4 39 a8 4f 79 15 21  |.....,....9.Oy.!|
00000100  3d 45 49 4f 4d d9 cb 40  e7 32 e4 cd 55 ec 6a 69  |=EIOM..@.2..U.ji|
00000110  5e d5 46 5e 16 d9 7e d2  78 83 74 8c 73 d8 fb 9e  |^.F^..~.x.t.s...|
00000120  41 bb a8 83 9b f2 b8 19  8f ff 09 a0 1c 7c 05 50  |A............|.P|
00000130  57 c3 98 88 ec 67 fc 7e  c2 b8 7b 0b fa 93 9c 01  |W....g.~..{.....|
00000140  e8 1e ea 55 d2 fd a5 a6  fb 0a fc 65 9d 8f bc 78  |...U.......e...x|
00000150  d8 d8 17 d5 f9 f2 20 dd  bf 3b 4c ba aa 93 be 6a  |...... ..;L....j|
00000160  f6 ef bb 4f 27 d6 a9 a8  31 f7 a8 27 fb 33 f4 01  |...O'...1..'.3..|
00000170  3f 50 bf 2a a2 d3 24 9d  f7 8f 70 28 8b db e8 34  |?P.*..$...p(...4|
00000180  1c fd ee ac 4c 5a 6f be  34 d6 7b 5f 1d 77 52 af  |....LZo.4.{_.wR.|
00000190  4e 1a e3 0b 73 b2 9b e0  27 f0 b3 cc cf b4 2d ed  |N...s...'.....-.|
000001a0  90 6f a2 68 3b db 40 36  ca a0 e1 f9 c4 61 7c 44  |.o.h;.@6.....a|D|
000001b0  19 0c 95 f6 6b b4 8d ad  7a 6e d0 88 f2 9e 00 d1  |....k...zn......|
000001c0  c6 ff 83 d1 c6 ff 02 00  00 00 00 a8 6e 18 00 d1  |............n...|
000001d0  c6 ff 05 d1 c6 ff c2 ae  6e 18 40 f9 7f 00 00 00  |........n.@.....|
000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200


=============================== StdErr Messages: ===============================

awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
share|improve this question
    
The easiest way is probably to use Wubi to install a copy of Ubuntu on Windows (as a virtual hard disk), and figure out what it does with the GRUB files, then replicate it in your actual partition. –  Mehrdad Dec 25 '11 at 22:04
    
@Mehrdad, thanks. I'll try that if user51166's answer doesn't fix it for me. –  Ben Lee Dec 25 '11 at 22:17

2 Answers 2

Are you sure the (hd1,1) is correct ? The ",1" surely is since GRUB2 starts numerating partitions and hard disk from 1 and not 0 as of GRUB (legacy).

EDIT: I'm also wrong, GRUB2 starts numerating partitions from 1, but hard disks are still counted from 0 upwards. Thanks to @Walter Maier-Murdnelch for pointing this out.

Might you try

#! /bin/sh -e
echo Adding Windows >&2
cat << EOF
menuentry "Windows 7″ {
    set root='(hd1,mdsos1)'
    chainloader +1
}

That is the brief version. Please include the single quotes (') in your GRUB2 configuration file.

Otherwise / furthermore you may try to use something like "os prober" which is specific to Debian and its derivates distributions. Basically windows should be detected automatically. Try to run

sudo os-prober

from the shell.

Otherwise try to adapt your code to match mine

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows 7 (loader) (on /dev/sde1)" --class windows --class os {
        insmod part_msdos
        insmod ntfs
        set root='(hd4,msdos1)'
        search --no-floppy --fs-uuid --set=root <UUID>
        chainloader +1
}

I think (besides the insmod instructions) and the "search ..." line (you can find the partition UUID by typing blkid in the shell) you need to specify the partition table's type (",msdos1" instead of ",1").

share|improve this answer
    
I didn't realize grub2 started numbering hard disks at 1, so I suspect your first solution will probably work. But right now I'm out of town and my computer isn't with me, so I'll have to try (hd2,1) when I get back late this week. If that doesn't fix it, I'll try matching your config. Thanks! (I already tried os-prober, but it didn't appear to do anything at all). I'd upvote you but I spent all my rep on the bounty and now don't have enough to upvote... Anyway, I'll let you know how this works and award the bounty if it does. –  Ben Lee Dec 25 '11 at 22:16
    
OK. I may also tell you another possible solution. For instance I encrypted my whole Notebook with truecrypt. At boot either I enter truecrypt's password, either I press ESC and get to grub's bootloader (if grub has been installed in a partition and not the MBR). –  user51166 Dec 25 '11 at 22:23
    
Otherwise you might "chainloading" to grub(2) from windows boot loader. See this for instance: sevenforums.com/installation-setup/…. However I normally prefer GRUB2 which is (normally) painless. Last would be downgrade to GRUB (legacy) which is still more stable and easy to configure in my opinion. I'm not very at ease with GRUB2 as well. Using Mehrdad's solution would probably be the easiest thing to do (but it will then install Ubuntu inside an NTFS volume if I remember correctly), however I'm not sure if you'll be wanting to reinstall ubuntu. –  user51166 Dec 25 '11 at 22:31
    
I've actually been thinking of downgrading to the original grub anyway. grub2 has been nothing but a pain in the ass for me to config since it came out, and I never had a problem with the original grub. –  Ben Lee Dec 25 '11 at 22:37
    
If you're downgrading then remember to use root(hd0,0) or root(hd1,0) for the reason explained precedently. If you have an urgent need for windows your best bet may edit boot's order in the BIOS. Sometimes GRUB (and GRUB2) just refuses to work the way you expect to. –  user51166 Dec 25 '11 at 22:43

in ubuntu run:

sudo update-grub2

then boot from Windows 7 install DVD, it will say that there is a problem with boot and will fix it, don't go further, remove DVD and boot Windows from HDD. Eventually if you don't see the bootloader and if the boot goes straight to Windows without giving you a choice - then you have to reinstall the Grub only from Ubuntu live disk

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.