PDA

View Full Version : grub(boot loader) programming



amittvt
08-28-2012, 04:29 AM
Actually i need to construct a server with two hard disks
condition:

condition:

if(hd1 is crashed)
search for blank hard-disk
make grub entry as hd(0,1)

can any one assist me the way.

--
Thanks in advance

Salem
08-28-2012, 05:39 AM
If the first disk is trashed, where do you think grub will load from (not from the crashed hard disk).

You can set the BIOS boot order to try each hard disk in turn (until it finds a bootable disk), but that's about it.

amittvt
08-29-2012, 12:31 AM
Sir,
please look at the structure

BIOS---->GRUB---->Loades OS

idea is like this.
As one Hard Disc fails,it reboots..even after crash at least grub part remains with it

So,i am finding the mechanism that grub part of Crashed hard disc to be changed by some mechanism
and second Hard Disc will come into priority and starts booting.

so can you assist me a way??

amittvt
08-29-2012, 01:41 AM
Making it more understanding..
i want to edit my /boot/grub/grub.conf or /etc/grub.conf file.
but through some programming mechanism.

Salem
08-29-2012, 02:21 AM
If the hard disk has completely failed, then you're not going to be loading grub to begin with.

If the OS somehow managed to trash it's own partition (say corrupted a few files - say malware), then there isn't going to be a reliable test (http://en.wikipedia.org/wiki/Halting_problem) you can do to establish beforehand whether a particular disk image is actually bootable or not. All the necessary files may be there, but it could still lock up somewhere in the boot process.

Have you actually looked at the source code yet?

Somewhere (I'm guessing), a data structure will be created from a grub.conf file.

What you need to do is iterate through that data structure to find each bootable partition/image and perform whatever "validation" tests you feel are necessary. If the test fails, then you delete that entry from the data structure.

You present to the user what is left after you have done this.

amittvt
08-29-2012, 07:23 AM
Actually i want to edit "grub.conf" like this,




default=1
timeout=8


title Fedora(2.6)
root (hd0,0)
kernel /vmlin ro root=UUID=xxxx-xxxxx-xxxx-xxxx-xxxxx rhgb quiet
initrd /initrd-2.6
title Susee(2.8)
root (hd1,0)
kernel /vmlin ro root=UUID=yyyyyy-yyyyyy-yyyyy-yyyyy-yyyy rhgb quiet
initrd /initrd-2.8


Is it possible..
please add your comments