PDA

View Full Version : [ubuntu] Grub not loading Windows 7



slobo
February 13th, 2010, 05:48 AM
First off I want to apologise if this has been answered but I've spend all my afternoon trying to solve this without much luck. I found lot of information I think would help me but the problem is I just installed Ubuntu today for the first time so I don't know how things function at all, I'm a total noob at Linux so to say...

So here is what happened....

I've been running Windows 7 for a while now and I've really got interested in Ubuntu lately so I've decided to make a separate partition and install Ubuntu. Installation went all fine and I used Grub loader at restart to get into Ubuntu and everything is working fine (write now I'm typing in Ubuntu) but when I try to get into Windows 7, it goes into Recovery system for some reason. I found this exact problem that this guy had, but I don't understand how to fix it.

http://www.linuxforums.org/forum/ubuntu-help/81524-i-m-having-trouble-my-grub-help-here-pls.html

Here is pic of my grub loader
http://i243.photobucket.com/albums/ff2/SloboGTI/th_39fad454.jpg (http://s243.photobucket.com/albums/ff2/SloboGTI/?action=view&current=39fad454.jpg)

and when I go into Windows 7 and to edit the command this is what I get
http://i243.photobucket.com/albums/ff2/SloboGTI/th_fca2ba06.jpg (http://s243.photobucket.com/albums/ff2/SloboGTI/?action=view&current=fca2ba06.jpg)

and this is where I think the problem is...

I have read a lot about editing menu.lst but when I did
sudo getdit /boot/grub/menu.lst menu.lst opens up and its totally empty ?!?! So I assume I have to fix that. Well as you can see I am very confused by all of this and I think I'm very close to fixing it but can't figure it out. So if anyone knows the easiest way to fix this please contribute.

slobo
February 13th, 2010, 05:50 AM
I've also downloaded boot_info_script.sh and here are the results if this helps any...



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

=> Grub 2 is installed in the MBR of /dev/sda and looks on the same drive in
partition #5 for /boot/grub.
sda1: __________________________________________________ _______________________

File system: ntfs
Boot sector type: Windows Vista/7
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files/dirs: /BOOTMGR /boot/bcd

sda2: __________________________________________________ _______________________

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

sda3: __________________________________________________ _______________________

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

sda5: __________________________________________________ _______________________

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

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

Drive: sda ___________________ __________________________________________________ ___

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0xdd8dd952

Partition Boot Start End Size Id System

/dev/sda1 2,048 15,749,119 15,747,072 27 Hidden HPFS/NTFS
/dev/sda2 * 16,158,720 219,629,511 203,470,792 7 HPFS/NTFS
/dev/sda3 219,640,680 312,576,704 92,936,025 5 Extended
/dev/sda5 219,640,743 312,576,704 92,935,962 83 Linux


blkid -c /dev/null: __________________________________________________ __________

Device UUID TYPE LABEL

/dev/sda1 9E14604D14602B0B ntfs Recovery
/dev/sda2 B4A045CFA045992E ntfs
/dev/sda5 cac9db5e-d69e-46ab-9eda-2902c39e2cbc ext3

============================ "mount | grep ^/dev output: ===========================

Device Mount_Point Type Options

/dev/sda5 / ext3 (rw,errors=remount-ro)


=========================== sda5/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 /boot/grub/grubenv ]; then
have_grubenv=true
load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
saved_entry=${prev_saved_entry}
save_env saved_entry
prev_saved_entry=
save_env prev_saved_entry
fi
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set cac9db5e-d69e-46ab-9eda-2902c39e2cbc
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
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/white
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Ubuntu, Linux 2.6.31-19-generic" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
set quiet=1
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set cac9db5e-d69e-46ab-9eda-2902c39e2cbc
linux /boot/vmlinuz-2.6.31-19-generic root=UUID=cac9db5e-d69e-46ab-9eda-2902c39e2cbc ro quiet splash
initrd /boot/initrd.img-2.6.31-19-generic
}
menuentry "Ubuntu, Linux 2.6.31-19-generic (recovery mode)" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set cac9db5e-d69e-46ab-9eda-2902c39e2cbc
linux /boot/vmlinuz-2.6.31-19-generic root=UUID=cac9db5e-d69e-46ab-9eda-2902c39e2cbc ro single
initrd /boot/initrd.img-2.6.31-19-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
set quiet=1
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set cac9db5e-d69e-46ab-9eda-2902c39e2cbc
linux /boot/vmlinuz-2.6.31-14-generic root=UUID=cac9db5e-d69e-46ab-9eda-2902c39e2cbc ro quiet splash
initrd /boot/initrd.img-2.6.31-14-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set cac9db5e-d69e-46ab-9eda-2902c39e2cbc
linux /boot/vmlinuz-2.6.31-14-generic root=UUID=cac9db5e-d69e-46ab-9eda-2902c39e2cbc ro single
initrd /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows Vista (loader) (on /dev/sda1)" {
insmod ntfs
set root=(hd0,1)
search --no-floppy --fs-uuid --set 9e14604d14602b0b
chainloader +1
}
menuentry "Windows 7 (loader) (on /dev/sda2)" {
insmod ntfs
set root=(hd0,2)
search --no-floppy --fs-uuid --set b4a045cfa045992e
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 ###

=============================== 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 defaults 0 0
# / was on /dev/sda5 during installation
UUID=cac9db5e-d69e-46ab-9eda-2902c39e2cbc / ext3 errors=remount-ro 0 1
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0

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


115.1GB: boot/grub/core.img
115.0GB: boot/grub/grub.cfg
115.0GB: boot/initrd.img-2.6.31-14-generic
115.0GB: boot/initrd.img-2.6.31-19-generic
115.0GB: boot/vmlinuz-2.6.31-14-generic
115.0GB: boot/vmlinuz-2.6.31-19-generic
115.0GB: initrd.img
115.0GB: initrd.img.old
115.0GB: vmlinuz
115.0GB: vmlinuz.old

Luisnux
February 13th, 2010, 06:03 AM
To be honest the best way to fix that is reinstalling ubuntu 9.10. Grub 2's new interface is far too complex to try and fix without messing up, or at least it will take some time to learn. Say you've installed Ubuntu 9.10, after that you want to try going into both of those options that it gives you for vista. That is because windows 7 installs two boot partitions one of them is a FAT and the other one is you actual windows 7 OS partition. I had that similar issue with a new install on one of my buddies laptop. However I tried the next boot option and that one was the one that actually booted into vista. So in reality Grub was working, is just that it had an option for each of the two partitions that windows 7 had.

Xog
February 13th, 2010, 06:06 AM
Had a similar problem. It was due to having too many partitions.

I've got 1 hard drive. I originally had just windows XP installed, and split the drive into two.

Then later on I installed ubuntu, and I messed up the partition positioning. Ubuntu booted fine but loading windows gave me errors. Just a re-install with the correct logical/primary and swap partitions got it to work.

Hope this helps.

Luisnux
February 13th, 2010, 06:08 AM
I forgot to give you an example to make it easier, so here we go. On the pic that you gave of the original grub options, the second option "windows 7 loader on sda2" would have been the one that would have booted into windows, and if that one did not work you could also try the one before that (the one that says Vista boot loader). Hope this helps.

lindsay7
February 13th, 2010, 06:19 AM
type this into the terminal and see if it fixes things

sudo update-grub

you will be asked for your password. This is what you put in when you set up your installation. Type it in and hit enter. You will not see what you type in, that is just the way it works.

lindsay7
February 13th, 2010, 06:50 AM
If that does not work, try this. You need to boot up with the Ubuntu install disk and go to the terminal which you will find under the menu at the top of the screen. Go to Applications/accessories/terminal

and type the following


sudo -i

enter you password and press enter

grub-mkconfig
grub-install /dev/sda # It might be hda in some cases.
update-grub
You are done.

slobo
February 13th, 2010, 08:30 AM
Thanks everyone for the help.:p

I definitely want to try every option before reformatting the whole partition. If I run out of options I'll have to do that but I have a feeling it's still not going to recognise because some grub settings have not been changed.
:(



To be honest the best way to fix that is reinstalling ubuntu 9.10. Grub 2's new interface is far too complex to try and fix without messing up, or at least it will take some time to learn. Say you've installed Ubuntu 9.10, after that you want to try going into both of those options that it gives you for vista. That is because windows 7 installs two boot partitions one of them is a FAT and the other one is you actual windows 7 OS partition. I had that similar issue with a new install on one of my buddies laptop. However I tried the next boot option and that one was the one that actually booted into vista. So in reality Grub was working, is just that it had an option for each of the two partitions that windows 7 had.

slobo
February 13th, 2010, 08:31 AM
I forgot to give you an example to make it easier, so here we go. On the pic that you gave of the original grub options, the second option "windows 7 loader on sda2" would have been the one that would have booted into windows, and if that one did not work you could also try the one before that (the one that says Vista boot loader). Hope this helps.

I did this and it does the same thing as Windows 7 option, goes into recovery setup. :(

slobo
February 13th, 2010, 08:34 AM
If that does not work, try this. You need to boot up with the Ubuntu install disk and go to the terminal which you will find under the menu at the top of the screen. Go to Applications/accessories/terminal

and type the following


sudo -i

enter you password and press enter

grub-mkconfig
grub-install /dev/sda # It might be hda in some cases.
update-grub
You are done.

The first one did not help so when I got to the
grub-install /dev/sda it's telling me "No such file directory"
http://i243.photobucket.com/albums/ff2/SloboGTI/th_grub.png (http://s243.photobucket.com/albums/ff2/SloboGTI/?action=view&current=grub.png)

:(

slobo
February 13th, 2010, 08:45 AM
One thing that really confuses me is that I read a lot about people editing their menu.lst file. When I do
gksudo gedit /boot/grub/menu.lst the file opens up and it's totally empty! There is got to be something wrong with that.

meierfra.
February 13th, 2010, 09:09 AM
Grub seems to be configured correctly. (menu.lst is used by Legacy Grub, but you have Grub 2, which uses "grub.cfg")

I suggest to run a Window 7 automatic startup repair:

http://www.bleepingcomputer.com/tutorials/tutorial148.html

the direction are for Vista, but they also works for Window 7. If you don't have a Window 7 CD, you can get a recovery CD from here:
http://neosmart.net/blog/2008/windows-vista-recovery-disc-download/

lindsay7
February 13th, 2010, 09:13 AM
You have grub2 installed on this system and it does not use the menu.lst file so you will not edit it or need it. It is used on the old grub system.

It looks like you did not leave a space after grub-install and /dev/sda.

If so try it again.

lindsay7
February 13th, 2010, 09:20 AM
The instruction are for vista but windows 7 works the same way. meierfra. is alway correct about these things, I was not sure grub was installed correctly. It will not hurt to set it up again however. If you do not have the widows install disk, there are ways to work around it.

slobo
February 13th, 2010, 09:21 AM
You have grub2 installed on this system and it does not use the menu.lst file so you will not edit it or need it. It is used on the old grub system.

It looks like you did not leave a space after grub-install and /dev/sda.

If so try it again.

You were right sir, I didn't have a space there.

I tried it and it installed, updated so I restarted laptop and same thing. :(

slobo
February 13th, 2010, 09:23 AM
Grub seems to be configured correctly. (menu.lst is used by Legacy Grub, but you have Grub 2, which uses "grub.cfg")

I suggest to run a Window 7 automatic startup repair:

http://www.bleepingcomputer.com/tutorials/tutorial148.html

the direction are for Vista, but they also works for Window 7. If you don't have a Window 7 CD, you can get a recovery CD from here:
http://neosmart.net/blog/2008/windows-vista-recovery-disc-download/

Ok I will try that, I do have the installation disc.

Thank you for your input.

lindsay7
February 13th, 2010, 09:38 AM
Great, that should get your windows mbr reset. It is possible that doing this may mess up the grub file. If after doing the windows mbr reinstall you can boot into window but not ubuntu, run the commands that I gave you to reinstall grub and that should take care of things.

To meierfra., is there such a thing as an XP recovery disk that can be downloaded? I have been looking for one to put in my fix list. I thought I read about or saw one somewhere.

lindsay7
February 13th, 2010, 09:44 AM
Here are the details on fixing the windows mbr for vista or 7 using the windows install disk,


To Restore corrupted Windows Vista Master Boot Record(MBR),follow the simple procedures.

You can use the Bootrec.exetool in the Windows Recovery Environment (Windows RE) to troubleshoot and repair the following items in Windows Vista:

* A master boot record (MBR)
* A boot sector
* A Boot Configuration Data (BCD) store

Note When you are troubleshooting startup issues by using the Windows RE, you should first try the Startup Repair option in the System Recovery Options dialog box. If the Startup Repair option does not resolve the issue, or if you must troubleshoot more steps manually, use the Bootrec.exe tool.

To run the Bootrec.exe tool, you must start Windows RE. To do this, follow these steps:

* Put your Windows Vista installation disc in the disc drive, and then start the computer.
* Press a key when you are prompted.
* Select a language, a time, a currency, a keyboard or an input method, and then click Next.
* Click Repair your computer.
* Click the operating system that you want to repair, and then click Next.
* In the System Recovery Options dialog box, click Command Prompt.
* Type “Bootrec.exe”, (without the quotes) and then press ENTER.

Note: To start the computer from your Windows Vista installation DVD, your computer must be configured from BIOS to start from the DVD drive

Bootrec.exe options

The Bootrec.exe tool supports the following options. Use the option that is appropriate for your situation.

/FixMbr

The /FixMbr option writes a Windows Vista-compatible MBR to the system partition. This option does not overwrite the existing partition table. Use this option when you must resolve MBR corruption issues, or when you have to remove non-standard code from the MBR.

/FixBoot

The /FixBoot option writes a new boot sector to the system partition by using a boot sector that is compatible with Windows Vista. Use this option if one of the following conditions is true.

* The boot sector has been replaced with a non-standard Windows Vista boot sector.
* The boot sector is damaged.
* An earlier Windows operating system has been installed after Windows Vista was installed. In this scenario, the computer starts by using Windows NT Loader (NTLDR) instead of Windows Boot Manager (Bootmgr.exe).

meierfra.
February 13th, 2010, 10:28 AM
Great, that should get your windows mbr reset.
There usually is no reason to reset the Window MBR. There are only very rare case in which Grub is not able to boot Window and once has to restore the Windows MBR.


It is possible that doing this may mess up the grub file.
"startup repair" does not touch the MBR. So there shoudn't be any problems booting into Ubuntu.



Here are the details on fixing the windows mbr for vista or 7 using the windows install disk,

I much prefer "startup repair" to "bootrec". It does not erase the MBR, and in most case does a better job repairing bootmgr and bcd. Only if the boot sector is damaged one might have to look into bootrec.



is there such a thing as an XP recovery disk that can be downloaded?
http://www.webtree.ca/windowsxp/tools/bootdiscs/xp_rec_con.zip

lindsay7
February 13th, 2010, 10:35 AM
Thanks for the info and advice. I have had better luck with fixmbr then the repair option option but that was by system. I am living and learing.

Thanks again, and for the xp file.

Luisnux
February 14th, 2010, 01:19 AM
I don't kow how much info/stuff you've installed on your Ubuntu 9.10 system but considering the fact that Ubuntu 9.10 can be cofigured to be installed in less than 5 minutes, you might be better off reinstalling Ubuntu, of course fix the mbr or the bootrec for windows 7 first. That way although you might have to reconfigure your ubuntu installation-you'll end up saving all the time that you might spend trying to configure Grub 2. Believe me, I've created at least 15 multiboot systems including at least 1 version of windows + 1 version of mac and at least one version of linux, and sometimes a quick reinstallation like the one in that ubuntu offers is the safest bet.

meierfra.
February 14th, 2010, 01:21 AM
I don't kow how much info/stuff you've installed on your Ubuntu 9.10 system but considering the fact that Ubuntu 9.10 can be cofigured to be installed in less
One cannot solve a windows problem by reinstalling Ubuntu.

Luisnux
February 14th, 2010, 01:25 AM
You're right that's why I suggested for him to fix his mbr first :)

meierfra.
February 14th, 2010, 01:35 AM
Sorry, running fixmbr and then reinstalling Ubuntu makes no sense whatsoever. Any changes done by "fixmbr" will be overwritten by reinstalling Ubuntu. So why would you run fixmbr?

slobo
February 14th, 2010, 01:39 AM
Thanks guys I finally got em both working!
Grub is working fine, now If I can just figure out how to change it so Windows 7 comes fist in line and Ubuntu 2nd ?

http://i243.photobucket.com/albums/ff2/SloboGTI/th_39fad454.jpg (http://s243.photobucket.com/albums/ff2/SloboGTI/?action=view&current=39fad454.jpg)

meierfra.
February 14th, 2010, 01:48 AM
If I can just figure out how to change it so Windows 7 comes fist in line and Ubuntu 2nd ?



sudo mv /etc/grub.d/{30,09}_os-prober
sudo dpkg-divert --local --divert /etc/grub.d/09_os-prober --rename --add /etc/grub.d/30_os-prober
sudo update-grub

Thanks to the first command, update-grub will process Windows before Ubuntu, and so Windows will end up on the Grub menu before Ubuntu.

The second command makes sure that the change does not get overwritten during Grub updates.

slobo
February 14th, 2010, 02:11 AM
sudo mv /etc/grub.d/{30,09}_os-prober
sudo dpkg-divert --local --divert /etc/grub.d/09_os-prober --rename --add /etc/grub.d/30_os-prober
sudo update-grub

Thanks to the first command, update-grub will process Windows before Ubuntu, and so Windows will end up on the Grub menu before Ubuntu.

The second command makes sure that the change does not get overwritten during Grub updates.

i'm probably doing something wrong but its telling me "no such file or directory"

http://i243.photobucket.com/albums/ff2/SloboGTI/grub-1.png

meierfra.
February 14th, 2010, 02:22 AM
"no such file or directory"
That's weird. Did your revert to Legacy Grub?

Post the output of


grub-install -v
ls -l /etc/grub.d/

slobo
February 14th, 2010, 02:31 AM
http://i243.photobucket.com/albums/ff2/SloboGTI/grub-2.png

meierfra.
February 14th, 2010, 02:40 AM
It seems you run "sudo mv /etc/grub.d/{30,09}_os-prober" twice.

The first time it succesfully renamed "/etc/grub.d/30_os-prober" to "/etc/grub.d/09_os-prober". So the second time "/etc/grub.d/30_os-prober" no longer existed.

So everything is fine. Just continue with


sudo dpkg-divert --local --divert /etc/grub.d/09_os-prober --rename --add /etc/grub.d/30_os-prober
sudo update-grub

Mark Phelps
February 14th, 2010, 02:47 AM
There's an easier way to do this ... the way I did it, as follows:
1) Write down the full text of the GRUB menu line you want to be the default
2) Open a terminal and enter "gksudo gedit /etc/default/grub"
3) Near the top, you'll see a line that says "GRUB DEFAULT", after the "=", insert the following text "GRUB_DEFAULT="Windows 7 (loader) (on /dev/sda1)" [that's my line, I think yours has the same text]
4) Save the file
5) Run the command "sudo update-grub"
6) Reboot

Then, when the GRUB menu is displayed, the Windows 7 ... line will be highlighted as the default.

When you do it this way, adding or removing kernels does not change the GRUB default line.

meierfra.
February 14th, 2010, 02:59 AM
There's an easier way to do this ... the way I did it, as follows:
Doesn't seem any easier.


When you do it this way, adding or removing kernels does not change the GRUB default line.
Same is true for my method.

Edit: I thought slobo's wanted Window to appear on top of the Grub menu. After reading, it seems slob's just wants Windows to be the default boot. For changing the default boot, I usually recommend the same method as Mark Phelp, just since renaming "30_osprober" is a little bit of a hack.