Grub, Problem with installing to correct area and loading.
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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:-
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 ....
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
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.
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.
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.