How can I get GRUB to detect the hard drives the same with each boot?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
How can I get GRUB to detect the hard drives the same with each boot?
Let me try to explain my problem. I have a system with three identical hard drives. Two drives are used in a RAID 1 array, the third drive is used as a backup drive. The two RAID drives are connected to SATA 1 and SATA 2 on my computer. The third is connected to SATA 3.
Let me call the two RAID drives HDD-R1 and HDD-R2, and the backup drive HDD-BU. At boot, grub numbers them as follows:
HDD-R1: hd0
HDD-R2: hd1
HDD-BU: hd2
In my grub menu.lst, I have setup grub to first try to boot from hd0 (the first RAID drive), and if that fails try to boot from hd1 (the second RAID drive).
For testing the RAID, I simulated a fatal disk failure by disconnecting HDD-R1. The system booted fine. I then reconnected HDD-R1 and removed HDD-R2. Again in booted fine. I reconnected both HDD-R1 and HDD-R2 and tested the fallback again, but this time by simply choosing from which harddrive to boot from the grub menu. When I chose to boot from hd0, all was fine. But when I chose to boot from hd1, it gave me an "Error 15: File not found".
It took me a while to figure out what had happened.
When I first disconnected HDD-R1, grub renumbered the drives as follows:
HDD-R2: hd0
HDD-BU: hd1
It booted fine, not because grub chose the fallback boot drive, but because it simply succeeded booting from hd0, the default boot option.
When I removed HDD-R2 and reconnected HDD-R1, grub numbered the drives as follows:
HDD-R2: hd0
HDD-BU: hd1
Again, it succeeded to boot using the default boot option.
In the last test, when I reconnected HDD-R1 again, grub numbered the drives as follows:
HDD-R2: hd0
HDD-BU: hd1
HDD-R1: hd2
You can see the obvious problem here. Grub will not be able to boot from the fallback drive since hd1 no longer is the second RAID drive, but the backup drive. This of course defeats the purpose of a RAID 1 setup.
So how can I get grub to number the drives the same each and every time? Perhaps label the drives and have grub check the volume labels instead of the physical boot order?
I think you need to change your point of focus. Grub doesn't do the hardware detection. The BIOS has hardware information, but it isn't passed on the the OS. So, the hardware detection is done somewhere else.
I think you should start looking into udev rules and persistent device names.
title linux
kernel (hd0,0)
/boot/vmlinuz BOOT_IMAGE=linux root=/dev/hda1 acpi=on splash=silent vga=788
initrd (hd0,0)/boot/initrd.img
"/dev/hda1" is a kernel command-line parameter. Not a grub parameter. So changing it to a persistent device name with udev (in, for instance, "/dev/disk/by-name/raid1") won't help grub to find the right drive.
grub at mbr or at boot partition does not understand devices under /dev or udev or sysfs so forget it.
but zippy...its not clear to me...that you have realised you have 3 mbrs...each mbr should have a bootloader if what you are trying to do...is test the fail of a drive.
its easy to put a bootloader into each drive's mbr.....then change the bios boot order or remove cables to test that bios jumps to drive x mbr and then to grub and then to its booting files.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.