grub(boot loader) programming

This is a discussion on grub(boot loader) programming within the Linux Programming forums, part of the Platform Specific Boards category; Actually i need to construct a server with two hard disks condition: condition: if(hd1 is crashed) search for blank hard-disk ...

  1. #1
    Registered User
    Join Date
    Aug 2012
    Location
    Delhi,India
    Posts
    4

    grub(boot loader) programming

    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

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535
    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.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Aug 2012
    Location
    Delhi,India
    Posts
    4
    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??

  4. #4
    Registered User
    Join Date
    Aug 2012
    Location
    Delhi,India
    Posts
    4
    Making it more understanding..
    i want to edit my /boot/grub/grub.conf or /etc/grub.conf file.
    but through some programming mechanism.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535
    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 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.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Aug 2012
    Location
    Delhi,India
    Posts
    4
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GRUB from windows
    By underline_bruce in forum Linux Programming
    Replies: 2
    Last Post: 07-08-2008, 05:34 AM
  2. like grub or lilo
    By enjoy in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 10-24-2007, 10:43 AM
  3. Contract work. Boot loader.
    By Kennedy in forum Projects and Job Recruitment
    Replies: 4
    Last Post: 12-05-2006, 02:48 AM
  4. Grub
    By Wraithan in forum Tech Board
    Replies: 4
    Last Post: 07-27-2006, 05:21 PM
  5. getting rid of grub
    By axon in forum Tech Board
    Replies: 3
    Last Post: 03-17-2004, 06:15 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21