LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Grub, Problem with installing to correct area and loading. (https://www.linuxquestions.org/questions/linux-general-1/grub-problem-with-installing-to-correct-area-and-loading-666276/)

maxvonseibold 08-29-2008 07:25 AM

Grub, Problem with installing to correct area and loading.
 
Hello,

I am having major problems with grub.

My setup is:-

A Dell Precision 390.

Two Sata, 160 gig hard drives sda and sdb

I have RHEL5 and Debian on SDB (the Second hard drive) partitions 1 and 2.

I want to put Ubuntu on SDA1 (the first hard drive).


The install process is fine but I cannot get the installer to update the existing grub on sdb which loads RHEL and Debian.
I have tried manually adding an entry to menu.lst for the sdb grub but attempts at booting result in:-

Code:

Error 15 or "Error 17 :  Cannot Mount the selected partition" errors.

I have also tried to install grub using 'grub-install' with the following:-


Code:

grub-install /dev/sda1
Code:

Searching for GRUB installation directory ... found: /boot/grub
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(hd0)        /dev/sda
(hd1)        /dev/sdb
machine_name:~# ls /boot/


This looks encouraging but when I ls the drive there is only the following:-


Code:

abi-2.6.24-19-generic         
initrd.img-2.6.24-19-generic       
System.map-2.6.24-19-generic
config-2.6.24-19-generic 
memtest86+.bin               
vmlinuz-2.6.24-19-generic


i.e. the Kernel images are there, but no way of loading them.


Code:

grub-install --root-directory=/boot /dev/sda2
This put a boot directory into the existing one on sdb which is not what I want!

I tried mounting sda1 to mnt and then doing:-

Code:

machine_name:/mnt# grub-install --root-directory=/mnt /dev/sda1
mkdir: cannot create directory `/mnt/boot': Read-only file system

No luck there either.


Code:

fdisk /dev/sda > p

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          37      297171  83  Linux
/dev/sda2              38        9598    76798732+  83  Linux
/dev/sda3            9599      19452    79152255  83  Linux


sda1 is a 300m boot partition where I would like grub to go.
sda2 is for /


In the BIOS settings there is NO way to specify the hard drive order. SO I tried physically swapping the cables over, but the message stated that it could not find an OS to load ....

Can anyone advise me on what to do here!

Many Thanks,



Max.

pixellany 08-29-2008 09:18 AM

I can't follow all those details, so let's start from the beginning.

If you want a drive to be bootable, there must be boot code in the MBR of the drive (the first sector). Putting GRUB on a partition does no good unless there is something that links to it.

Assuming that you can boot into something, all you have to do is edit the appropriate menu.lst to point to the other drive. When GRUB is installed to the MBR, it gets "hard-coded" to point to the partition containing its files. If you don't know where this is, just look at all the possibilities until you see the menu.lst that matches what you see on the GRUB menu at startup.

Once you are booted into a working Linux, then proceed as follows:
fdisk -l ....##to confirm the drive numbering
Locate the correct menu.lst file
lets assume that Ubuntu is on sdb1, and there is no separate /boot partition. The menu.lst entry will look like this:
title Ubuntu
root (hd1,0) ...##This is Grub's way of saying 2nd drive, 1st partition
kernel /boot/vmlinuz...... root=/dev/sdb1 ro
initrd /boot/initrd....
boot

I always alias the vmlinuz..... and initrd..... filenames to simply "vmlinuz" and "initrd". Then I don't have to know the actual names when setting up menu.lst entries.

Note the two "root" statements: The first one tells GRUB where the boot files are. The second one tells the kernel where to mount "/"--ie the root of the filesystem

More gory details in the "booting" link below

Larry Webb 08-29-2008 09:40 AM

Let us see just plain fdisk -l, it appears that you have linux on sda. Do you want to point grub to its own partition?

maxvonseibold 08-29-2008 09:43 AM

Thanks pixellany,

I was unclear on the aspect of the MBS pointing to grub.

However, what is strange from this is that I did have a working grub from the original Debian installation. This grub could boot both linuxes of their own (second) hard drive and also boot a windows xp which had previously been on the first (sda) hard disk.

So from this I deduced that this grub can access both disks because it has done on many prior occations.

Soooooo... Surely adding a new entry to menu.lst as you suggested:-

Quote:

Code:

title Ubuntu
root (hd1,0) ...##This is Grub's way of saying 2nd drive, 1st partition
kernel /boot/vmlinuz...... root=/dev/sdb1 ro
initrd /boot/initrd....
boot


and then pointing the root and kernel at the new Ubuntu should make it work?

Despite these attempts I kept getting the Error 15 and 17 messages.

I also tried manually doing this when grub loaded and entering the grub shell to type the entries in myself and it still refuses to mount the first hard disk and start the boot sequence off.

Thanks for your feedback though, it has helped clarify several things.


Max.

amani 08-29-2008 10:05 AM

Try to use uuids
Your bios maybe complicating the drive order.
(hd1,0) maybe (hd0,0) relative Ubuntu!

The easiest thing to do is

Install one grub to the MBR.
Install the grub of others to their root partition and chainload them from the original grub.

yancek 08-29-2008 12:11 PM

Your entries with a separate /boot partition are going to be very different than if you install Grub stage1 to mbr and the rest of the Grub bootloader to the root partition. I would suggest you check out and read the information on this link, it's specific to Ubuntu but the info on Grub would be the same.

http://users.bigpond.net.au/hermanzo...boot_partition

I'd agree with amani about chainloading being the easiest.

maxvonseibold 09-01-2008 03:06 AM

Hi guys,

I need to cram up on what you have just posted so let me have a read and I will try and reply asap.

Yancek, I did try running grub-install normally and with the seperate /boot partition after the first approach kept installing the files into a directory inside/boot/ on the already booted sdb drive.

Somewhere along the line here I seem to have got very muddled indeed.

Regarding the chainloading of grubs to grubs. Would this result the first grub menu appearing and then upon a selection, having a second new grub menu appear?

Thanks,


Max.

Larry Webb 09-01-2008 06:56 AM

On the chainloading that is right, a second grub menu.lst will appear, but you can almost eliminate it by changing the timeout to 1. You have to make sure the default selection is the os that you want to boot.

pixellany 09-01-2008 07:05 AM

You can also hide the menu.....

http://www.gnu.org/software/grub/man...tml#hiddenmenu


All times are GMT -5. The time now is 03:33 PM.