bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GRUB, Savedefault & MBR


From: Carret, Christophe
Subject: GRUB, Savedefault & MBR
Date: Mon, 25 Aug 2003 10:58:54 +0100


Hello,

I am working on a project where we attempt to get a copy of the MBR including the current default option after using the savedefault option available in GRUB. My question is related to the place where the MBR is located on the physical disk.

I executed the tests described above:

        - 2 grub menu options execute exactly the same actions.
        Both have the "savedefault" command in their menu line. The default for the file is set to "saved".

        - First boot, I select first menu line. After the boot, I save the beginning of disk hda:
                # dd if=/dev/hda of=./MBR1 bs=512 count=100
                # reboot

        - Second boot, the first menu line is the default option.
        I select 2nd menu line and boot. After the boot, I save the beginning of disk hda again:
                # dd if=/dev/hda of=./MBR2 bs=512 count=100
                # reboot

        - Third reboot, the second menu line is the default option.
        I reboot using 1st menu line and go to compare the results of the two precedent dd commands:

                # cmp ./MBR1 ./MBR2

        The files are the sames !!

So I wanted to know where does GRUB store the MBR on the disk.
Or more precisely where does GRUB save the default option.

Looking at the code, it seems that the file stage2/asm.S talks about saving it in the 2d sector, but in this case, why cannot I see the change when accessing the raw device /dev/hda ?

In fact, what we want to do is to dynamically change the default option by accessing directly to the MBR without changing the default choice in the menu file. As one of our programs is a standalone 16 bits program not accessing the disk, we consider it is simpler to use the int13h bios command from this program and access the raw device from the Linux Red-hat 7.4 user level program. For this, we imperatively need to know where this option is stored.

Any help would be appreciated.

Thanks,

Christophe Carret,
StorageTek, France


reply via email to

[Prev in Thread] Current Thread [Next in Thread]