where does grub put the MBR?

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

where does grub put the MBR?

Hugo Vanwoerkom
Hi,

Is there a way to know *for sure* where grub puts the MBR? (No setup
command)

/grub/device.map has:
hd0=/dev/hda
hd1=/dev/sda

and menu.lst has:

=============================================================
#
default         2
#
timeout         5
# Pretty colours
color cyan/blue white/blue
# ...
title           Debian GNU/Linux, kernel 2.6.16-ck8
root            (hd1,2)
kernel          /boot/vmlinuz-2.6.16-ck8 root=/dev/sda3 ro quiet
savedefault
boot

title           Debian GNU/Linux, kernel 2.6.16-ck8 (recovery mode)
root            (hd1,2)
kernel          /boot/vmlinuz-2.6.16-ck8 root=/dev/sda3 ro single
savedefault
boot

title           Debian GNU/Linux, kernel 2.6.8-2-386
root            (hd1,2)
kernel          /boot/vmlinuz-2.6.8-2-386 root=/dev/sda3 ro quiet vga=788
initrd          /boot/initrd.img-2.6.8-2-386
savedefault
boot

title           Debian GNU/Linux, kernel 2.6.8-2-386 (recovery mode)
root            (hd1,2)
kernel          /boot/vmlinuz-2.6.8-2-386 root=/dev/sda3 ro single
initrd          /boot/initrd.img-2.6.8-2-386
savedefault
boot

=============================================================

But the way hda is setup (on VMware) is like this:

    Device    Boot      Start         End      Blocks   Id  System
    /dev/hda1               1         973     7815591   2d  Unknown
    /dev/hda2             974        1946     7815622+  2d  Unknown
    /dev/hda3            1947        2919     7815622+  2d  Unknown
    /dev/hda4            2920        9729    54701325    5  Extended
    /dev/hda5            2920        3892     7815591   2d  Unknown
    /dev/hda6            3893        4865     7815591   2d  Unknown
    /dev/hda7            4866        9729    39070048+  83  Linux

So does he put the MBR on /dev/hda or /dev/hda7?

Thanks!

H









--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: where does grub put the MBR?

Roberto C. Sanchez
Hugo Vanwoerkom wrote:
> Hi,
>
> Is there a way to know *for sure* where grub puts the MBR? (No setup
> command)
>

Well the MBR, is always in the same place.  It is *always* the first 512
bytes on the physical disk.  Now, what I think you want to ask is,
"where does grub install itself?"  As to that, I don't know, other than
scanning the disk and its partitions to see.  Though, I am not certain
how one would do that.

-Roberto

--
Roberto C. Sanchez
http://familiasanchez.net/~roberto

signature.asc (264 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: where does grub put the MBR?

Hugo Vanwoerkom
Roberto C. Sanchez wrote:

> Hugo Vanwoerkom wrote:
>> Hi,
>>
>> Is there a way to know *for sure* where grub puts the MBR? (No setup
>> command)
>>
>
> Well the MBR, is always in the same place.  It is *always* the first 512
> bytes on the physical disk.  Now, what I think you want to ask is,
> "where does grub install itself?"  As to that, I don't know, other than
> scanning the disk and its partitions to see.  Though, I am not certain
> how one would do that.
>
> -Roberto
>

And what would I look for?

H


--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: where does grub put the MBR?

Alvin Oga


On Wed, 3 May 2006, Hugo Vanwoerkom wrote:

> Roberto C. Sanchez wrote:
> > Hugo Vanwoerkom wrote:
> >> Hi,
> >>
> >> Is there a way to know *for sure* where grub puts the MBR? (No setup
> >> command)

yes...

> > Well the MBR, is always in the same place.  It is *always* the first 512
> > bytes on the physical disk.

the MBR is the first 446 bytes of each partition ....
        16 bytes for each of the 4 primary partition
         2 bytes for the boot flag

and if you have more than one partition, the "boot record" is the
first 448 bytes of each primary primary

>  Now, what I think you want to ask is,
> > "where does grub install itself?"  As to that, I don't know, other than
> > scanning the disk and its partitions to see.  Though, I am not certain
> > how one would do that.

grub stage1 or lilo, etc is loaded by the bios into 0x7C00
grub stage1.5 is loaded by the bios into 0x8K

> And what would I look for?

you don't ...  but if you insist... use a diskeditor to read the contents
of any random cylinder/head/sector "to look for" stuff

c ya
alvin


--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: where does grub put the MBR?

Willie Wonka
In reply to this post by Hugo Vanwoerkom
Alvin Oga wrote:
> On Wed, 3 May 2006, Hugo Vanwoerkom wrote:
>
> > Roberto C. Sanchez wrote:
> > > Hugo Vanwoerkom wrote:
> > >> Hi,
> > >>
> > >> Is there a way to know *for sure* where grub puts the MBR? (No
setup
> > >> command)
>
> yes...
>
> > > Well the MBR, is always in the same place.  It is *always* the
first 512

> > > bytes on the physical disk.
>
> the MBR is the first 446 bytes of each partition ....
> 16 bytes for each of the 4 primary partition
> 2 bytes for the boot flag
>
> and if you have more than one partition, the "boot record" is the
> first 448 bytes of each primary primary
>
> >  Now, what I think you want to ask is,
> > > "where does grub install itself?"  As to that, I don't know,
other than
> > > scanning the disk and its partitions to see.  Though, I am not
certain
> > > how one would do that.
>
> grub stage1 or lilo, etc is loaded by the bios into 0x7C00
> grub stage1.5 is loaded by the bios into 0x8K
>
> > And what would I look for?
>
> you don't ...  but if you insist... use a diskeditor to read the
contents
> of any random cylinder/head/sector "to look for" stuff.


To expand just a bit on alvin's comments (who knows more than I about
this I'm sure) and I'm not sure how this will help you, but;

As a user from a terminal/console;

~$ sudo dd if=/dev/hda bs=512 count=2 | xxd

        0000000: eb48 90d0 bc00 7cfb 5007 501f fcbe 1b7c  .H....|.P.P....|
        0000010: bf1b 0650 57b9 e501 f3a4 cbbe be07 b104  ...PW...........
        0000020: 382c 7c09 7515 83c6 10e2 f5cd 188b 148b  8,|.u...........
        0000030: ee83 c610 4974 1638 2c74 f6be 1007 0302  ....It.8,t......
       
        ....
       
        0000160: 00eb 0ebe 847d e838 00eb 06be 8e7d e830  .....}.8.....}.0
        0000170: 00be 937d e82a 00eb fe47 5255 4220 0047  ...}.*...GRUB .G
        0000180: 656f 6d00 4861 7264 2044 6973 6b00 5265  eom.Hard Disk.Re
        0000190: 6164 0020 4572 726f 7200 bb01 00b4 0ecd  ad. Error.......
       
        ....
       
        0000300: 00eb fe4c 6f61 6469 6e67 2073 7461 6765  ...Loading stage
        0000310: 312e 3500 2e00 0d0a 0047 656f 6d00 5265  1.5......Geom.Re
        0000320: 6164 0020 4572 726f 7200 bb01 00b4 0ecd  ad. Error.......
       
        ....
       
        0000410: 0200 302e 3935 00ff ff00 812f 626f 6f74  ..0.95...../boot
        0000420: 2f67 7275 622f 7374 6167 6532 202f 626f  /grub/stage2 /bo
        0000430: 6f74 2f67 7275 622f 6d65 6e75 2e6c 7374  ot/grub/menu.lst
       
       

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 


--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: where does grub put the MBR?

Mike McCarty
In reply to this post by Alvin Oga
Alvin Oga wrote:

>
> On Wed, 3 May 2006, Hugo Vanwoerkom wrote:
>
>
>>Roberto C. Sanchez wrote:
>>
>>>Hugo Vanwoerkom wrote:
>>>
>>>>Hi,
>>>>
>>>>Is there a way to know *for sure* where grub puts the MBR? (No setup
>>>>command)
>
>
> yes...
>
>
>>>Well the MBR, is always in the same place.  It is *always* the first 512
>>>bytes on the physical disk.
>
>
> the MBR is the first 446 bytes of each partition ....
> 16 bytes for each of the 4 primary partition
> 2 bytes for the boot flag

The MBR is the first sector (512 bytes) of a hard disc. It is
also sometimes called the Boot Label. As part of a standard
MBR is a Partition Table. The part of the MBR which is not
in the Partition Table is 446 bytes.

> and if you have more than one partition, the "boot record" is the
> first 448 bytes of each primary primary

The Boot Record (BR) is the first 512 bytes of the partition. It
contains the BIOS Parameter Block (BPB). It is also sometimes
called the "geometry" of the partition.

>> Now, what I think you want to ask is,
>>
>>>"where does grub install itself?"  As to that, I don't know, other than
>>>scanning the disk and its partitions to see.  Though, I am not certain
>>>how one would do that.
>
>
> grub stage1 or lilo, etc is loaded by the bios into 0x7C00
> grub stage1.5 is loaded by the bios into 0x8K

The question AIUI has nothing to do with memory addresses.
GRUB is initially loaded into 0000:7C00. GRUB loads succeeding
stages into memory itself, not the BIOS, unless you call
GRUB making BIOS calls to use the disc read routines "the BIOS
loading GRUB stage1.5".

>>And what would I look for?
>
>
> you don't ...  but if you insist... use a diskeditor to read the contents
> of any random cylinder/head/sector "to look for" stuff

Less than useful reply. He can use dd to read the disc, using
information obtained using

# fdisk -l

Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!


--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: where does grub put the MBR?

Mike McCarty
Mike McCarty wrote:

[snip]

> The MBR is the first sector (512 bytes) of a hard disc. It is
> also sometimes called the Boot Label. As part of a standard

OUCH! Of course, I meant "Disc Label".

I can't believe I wrote that. (Read first, then hit "Send";
Read first, then hit "Send"...)

[snip]

Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!


--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: where does grub put the MBR?

Nate Bargmann
In reply to this post by Alvin Oga
* Alvin Oga <[hidden email]> [2006 May 03 07:06 -0500]:

> > > Well the MBR, is always in the same place.  It is *always* the first 512
> > > bytes on the physical disk.
>
> the MBR is the first 446 bytes of each partition ....
> 16 bytes for each of the 4 primary partition
> 2 bytes for the boot flag
>
> and if you have more than one partition, the "boot record" is the
> first 448 bytes of each primary primary

So, the MBR (first 512 octets) contains the partition information for
up to four primary partitions or one to three primaries and one extended.
Where are succeeding partition (hda5 and higher) records kept for
partitions in an extended partition?

- Nate >>

--
 Wireless | Amateur Radio Station N0NB          |  Successfully Microsoft
  Amateur radio exams; ham radio; Linux info @  | free since January 1998.
             http://www.qsl.net/n0nb/           |  "Debian, the choice of
             My Kawasaki KZ-650 SR @            |     a GNU generation!"
        http://www.networksplus.net/n0nb/       |   http://www.debian.org


--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: where does grub put the MBR?

Digby Tarvin
On Thu, May 04, 2006 at 04:16:08PM -0500, Nate Bargmann wrote:

> * Alvin Oga <[hidden email]> [2006 May 03 07:06 -0500]:
>
> > > > Well the MBR, is always in the same place.  It is *always* the first 512
> > > > bytes on the physical disk.
> >
> > the MBR is the first 446 bytes of each partition ....
> > 16 bytes for each of the 4 primary partition
> > 2 bytes for the boot flag
> >
> > and if you have more than one partition, the "boot record" is the
> > first 448 bytes of each primary primary
>
> So, the MBR (first 512 octets) contains the partition information for
> up to four primary partitions or one to three primaries and one extended.
> Where are succeeding partition (hda5 and higher) records kept for
> partitions in an extended partition?

In the extended partitions themselves. The extended partition has its
own MBR which contains two partitions entries - one for a logical
partition, and the second for another 'extended partition' which
repeats the process.

Hence there is no limit to the number of logical partitions, but if a
logical partition is corrupted, you lose all of the partitions which follow.

This is the output of a program I wrote some time ago to display all of
the partitioning information on my drives:

[LILO] Master Boot Record 00000000:00000000
[MWIN] Part 0: 00 01-000-01 06 fe-0c2-3f 0000003f  3132612 (DOS 16-bit >=32)
[BSDI] Part 1: 00 00-0c3-01 9f fe-185-3f 002fcd03  3132675 (BSD/OS)
       Part 2: 00 00-186-01 83 fe-247-3f 005f9a06  3116610 (Linux native)
       Part 3: 00 00-248-01 05 fe-3ff-3f 008f2848 146914425 (Extended)
       Master Boot Record 00000000:008f2848
[MWIN] Part 0: 00 01-248-01 06 fe-287-3f 0000003f  1028097 (DOS 16-bit >=32)
       Part 1: 00 00-288-01 05 fe-298-3f 000fb040   273105 (Extended)
       Master Boot Record 000fb040:008f2848
[LILO] Part 0: 00 01-288-01 83 fe-298-3f 0000003f   273042 (Linux native)
       Part 1: 00 00-299-01 05 fe-2a6-3f 0013db11   224910 (Extended)
       Master Boot Record 0013db11:008f2848
       Part 0: 00 01-299-01 82 fe-2a6-3f 0000003f   224847 (Linux swap)
       Part 1: 00 00-2a7-01 05 fe-3ac-3f 0017499f  4209030 (Extended)
       Master Boot Record 0017499f:008f2848
       Part 0: 00 01-2a7-01 83 fe-3ac-3f 0000003f  4208967 (Linux native)
        .
        .
        .

The bracketed information on the left identifies the type of boot
code found in the first sector of the partition.

Regards,
DigbyT
--
Digby R. S. Tarvin                                          digbyt(at)digbyt.com
http://www.digbyt.com


--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: where does grub put the MBR?

Nate Bargmann
* Digby Tarvin <[hidden email]> [2006 May 04 18:46 -0500]:

> The bracketed information on the left identifies the type of boot
> code found in the first sector of the partition.

Thanks!  I should have asked this last fall when the subject came up in
an A+ class and the instructor was incorrect on this point.

- Nate >>

--
 Wireless | Amateur Radio Station N0NB          |  Successfully Microsoft
  Amateur radio exams; ham radio; Linux info @  | free since January 1998.
             http://www.qsl.net/n0nb/           |  "Debian, the choice of
             My Kawasaki KZ-650 SR @            |     a GNU generation!"
        http://www.networksplus.net/n0nb/       |   http://www.debian.org


--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: where does grub put the MBR?

Hugo Vanwoerkom
In reply to this post by Digby Tarvin
Digby Tarvin wrote:

> On Thu, May 04, 2006 at 04:16:08PM -0500, Nate Bargmann wrote:
>> * Alvin Oga <[hidden email]> [2006 May 03 07:06 -0500]:
>>
>>>>> Well the MBR, is always in the same place.  It is *always* the first 512
>>>>> bytes on the physical disk.
>>> the MBR is the first 446 bytes of each partition ....
>>> 16 bytes for each of the 4 primary partition
>>> 2 bytes for the boot flag
>>>
>>> and if you have more than one partition, the "boot record" is the
>>> first 448 bytes of each primary primary
>> So, the MBR (first 512 octets) contains the partition information for
>> up to four primary partitions or one to three primaries and one extended.
>> Where are succeeding partition (hda5 and higher) records kept for
>> partitions in an extended partition?
>
> In the extended partitions themselves. The extended partition has its
> own MBR which contains two partitions entries - one for a logical
> partition, and the second for another 'extended partition' which
> repeats the process.
>
> Hence there is no limit to the number of logical partitions, but if a
> logical partition is corrupted, you lose all of the partitions which follow.
>
> This is the output of a program I wrote some time ago to display all of
> the partitioning information on my drives:
>
> [LILO] Master Boot Record 00000000:00000000
> [MWIN] Part 0: 00 01-000-01 06 fe-0c2-3f 0000003f  3132612 (DOS 16-bit >=32)
> [BSDI] Part 1: 00 00-0c3-01 9f fe-185-3f 002fcd03  3132675 (BSD/OS)
>        Part 2: 00 00-186-01 83 fe-247-3f 005f9a06  3116610 (Linux native)
>        Part 3: 00 00-248-01 05 fe-3ff-3f 008f2848 146914425 (Extended)
>        Master Boot Record 00000000:008f2848
> [MWIN] Part 0: 00 01-248-01 06 fe-287-3f 0000003f  1028097 (DOS 16-bit >=32)
>        Part 1: 00 00-288-01 05 fe-298-3f 000fb040   273105 (Extended)
>        Master Boot Record 000fb040:008f2848
> [LILO] Part 0: 00 01-288-01 83 fe-298-3f 0000003f   273042 (Linux native)
>        Part 1: 00 00-299-01 05 fe-2a6-3f 0013db11   224910 (Extended)
>        Master Boot Record 0013db11:008f2848
>        Part 0: 00 01-299-01 82 fe-2a6-3f 0000003f   224847 (Linux swap)
>        Part 1: 00 00-2a7-01 05 fe-3ac-3f 0017499f  4209030 (Extended)
>        Master Boot Record 0017499f:008f2848
>        Part 0: 00 01-2a7-01 83 fe-3ac-3f 0000003f  4208967 (Linux native)
> .
> .
> .
>
> The bracketed information on the left identifies the type of boot
> code found in the first sector of the partition.
>

Nice program. The reason I originally asked was that this a VMware VM
and it had Sarge 2.6.8 installed with grub. I restored Sarge with
2.6.16-ck8 with Lilo to it and was afraid that if I put the MBR with the
boot=hda sequence in a different place than grub had done it might not
boot any longer.


Who knows. I left it boot=hda and it booted OK with Lilo although hda is
a physical disk that has only one (the last) partition open R/W because
I don't know how to do that ro.

H.








--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: where does grub put the MBR?

Mike McCarty
In reply to this post by Digby Tarvin
Digby Tarvin wrote:

> On Thu, May 04, 2006 at 04:16:08PM -0500, Nate Bargmann wrote:
>
>>* Alvin Oga <[hidden email]> [2006 May 03 07:06 -0500]:
>>
>>
>>>>>Well the MBR, is always in the same place.  It is *always* the first 512
>>>>>bytes on the physical disk.
>>>
>>>the MBR is the first 446 bytes of each partition ....
>>> 16 bytes for each of the 4 primary partition
>>> 2 bytes for the boot flag
>>>
>>>and if you have more than one partition, the "boot record" is the
>>>first 448 bytes of each primary primary
>>
>>So, the MBR (first 512 octets) contains the partition information for
>>up to four primary partitions or one to three primaries and one extended.
>>Where are succeeding partition (hda5 and higher) records kept for
>>partitions in an extended partition?
>
>
> In the extended partitions themselves. The extended partition has its
> own MBR which contains two partitions entries - one for a logical
> partition, and the second for another 'extended partition' which
> repeats the process.

[snip]

Sorry to reply so late. There is exactly ONE MBR per disc. The extended
partition does indeed have information about volumes contained in it,
but this does not constitute an MBR.

Otherwise, good information.

Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!


--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]