LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Manually installing Grub (https://www.linuxquestions.org/questions/linux-newbie-8/manually-installing-grub-785357/)

dunraven23 01-28-2010 08:46 AM

Manually installing Grub
 
I installed OpenSUSE to an external USB HDD but had severe problems with Grub failing to boot Windows 7, although it booted the Linux OK. In the end I had to replace the Grub mbr code in the Ext HDD with W7 mbr code. So I now have a system with functioning W7 on my internal drive and a working install of OpenSUSE 11.2 on my external USB HDD that I can't currently boot.

Will it be possible to manually install Grub using grub-install to boot both the Windows and Linux distro?

My configuration is:

sda Internal 160 GB HDD all NTFS

sda1 Hidden OS reinstall 10GB
sda2 Windows 7 70GB (Active Partition, Bootable)
sda3 Data 70GB
sda4 Hidden Utils 5GB

sdb is a 64 GB USB Stick

sdc External USB HDD 500 GB

sdc1 /Root Ext4 12 GB
sdc2 /Home Ext4 10 GB
sdc3 NTFS 460 GB
sdc4 swap 5GB

I'd appreciate any help on how to write a suitable version of grub-install to place Grub in sda2 and call W7 from there and OpenSUSE from sdc1.

sohail0399 01-28-2010 08:49 AM

yes there is issues with dual boot but solution is also possible.

Boot into the live linux cd.

When you get to the desktop open a terminal and enter. (I am going to give you the commands and then I will explain them later)

Code:
sudo grub
This will get you a "grub>" prompt (i.e. the grub shell). At grub>. enter these commands

Code:
find /boot/grub/stage1
This will return a location. If you have more than one, select the installation that you want to provide the grub files.
Next, THIS IS IMPORTANT, whatever was returned for the find command use it in the next line (you are still at grub>. when you enter the next 3 commands)

Code:
root (hd?,?)
Again use the value from the find command i.e. if find returned (hd0,1) then you would enter root (hd0,1)

Next enter the command to install grub to the mbr

Code:
setup (hd0)
Finally exit the grub shell
Code:
quit

dunraven23 01-28-2010 09:34 AM

Quote:

Originally Posted by sohail0399 (Post 3843664)
yes there is issues with dual boot but solution is also possible.

Boot into the live linux cd.

When you get to the desktop open a terminal and enter. (I am going to give you the commands and then I will explain them later)

Code:
sudo grub
This will get you a "grub>" prompt (i.e. the grub shell). At grub>. enter these commands

Code:
find /boot/grub/stage1
This will return a location. If you have more than one, select the installation that you want to provide the grub files.
Next, THIS IS IMPORTANT, whatever was returned for the find command use it in the next line (you are still at grub>. when you enter the next 3 commands)

Code:
root (hd?,?)
Again use the value from the find command i.e. if find returned (hd0,1) then you would enter root (hd0,1)

Next enter the command to install grub to the mbr

Code:
setup (hd0)
Finally exit the grub shell
Code:
quit

I followed that exactly.

The find /boot.grub/stage1 command returned

hd2,0

I used that to go

root (hd2,0)

and then

setup (hd0).

On rebooting I was presented with all the correct choices by a Grub screen and Windows 7 boots correctly when selected. However when I select OpenSUSE I simply get the message:

Error 15 File not found.

What do I do to make OpenSUSE boot correctly?

sohail0399 01-28-2010 09:56 AM

why did not you try for hd2?

in command "setup (hd0)".

but i dont know the response for hd2, so if you can try?

dunraven23 01-28-2010 10:04 AM

I'll try setup (hd2) if it will allow me to change from hd0! I checked the kernel in /boot and that was the same as used by Grub so that doesn't appear to be the problem. I will post in a few minutes.

dunraven23 01-28-2010 10:29 AM

I've tried setup (hd2) in the above procedure and I still get the same error 15 file not found.

However I also noted that before the Grub menu appears I get another error saying hd1,0 /boot message missing.

W7 still boots OK.

sohail0399 01-28-2010 10:45 AM

this is good that you give feedback

ok! do for hd0 and try this at prompt

grub>
If you installed a /boot partition, do
Code:
find /grub/stage1
If you did not do a /boot partition [most likely choice] do
Code:
find /boot/grub/stage1


One of these commands will give you an answer like
Code:
root (hd0.0)
Now press Esc.
Select the first boot option and press "e"

Press "e" again on the root option
Change the hd(X,X) to whatever you got above. for me it was hd (0,0).
Press Enter.
Now press "b"

linux should load up.

Now that you are in, you need to change this for good.
Open a terminal and enter
Code:
sudo gedit /boot/grub/menu.lst
or, depending on your setup
Code:
sudo gedit /grub/menu.lst
Scroll down towards the bottom of the file, and you will find the same "root (hdX,X)" change it appropriately, and you can save!

dunraven23 01-28-2010 11:23 AM

Fine, I have changed the boot to hd2,0 in the Grub menu and then booted OpenSUSE. That worked. I would now like to amend menu.lst but gedit isn't available in my KDE version of OpenSUSE and when I download as zypper gedit the resulting gedit won't open menu.lst even though I try from a sudo su console in Terminal. It reports Gtk Warning cannot display. Can I use another in place of gedit?

dunraven23 01-28-2010 11:48 AM

I used VIM to edit menu.lst. Not the easiest to understand but it worked. I now have OpenSUSE booting correctly.

Many thanks for your help.


All times are GMT -5. The time now is 02:45 AM.