LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   volume boot record is the same as MBR? (https://www.linuxquestions.org/questions/linux-software-2/volume-boot-record-is-the-same-as-mbr-840822/)

miros84 10-27-2010 03:04 PM

volume boot record is the same as MBR?
 
Hello
If I have a HDD with 3 particions, I have 1 MBR at the begining of the HDD, and 3 VBR (volume boot record). One VBR for each partition in the begining of each partition. But what I dont understund is if first VBR in the first partition (512 bytes) are the same 512 bytes in MBR?

johnsfine 10-27-2010 03:39 PM

The first partition does not start at the very beginning of the hard drive.

Partitions normally start on "cylinder" boundaries, but I think the first partition normally starts one "track" later (than the start of the first "cylinder").

Of course on modern disks, "cylinder" and "track" are just units for the BIOS and don't correspond to the physical layout of the disk.

miros84 10-27-2010 03:54 PM

So, first 512 bytes of sda are diferents from first 512 bytes of sda1, right?

johnsfine 10-27-2010 04:20 PM

Quote:

Originally Posted by miros84 (Post 4141424)
So, first 512 bytes of sda are diferents from first 512 bytes of sda1, right?

Right.

Consider this example from one of my computers:

Code:

# /sbin/fdisk -l

Disk /dev/sda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1      37869  304182711  83  Linux
/dev/sda2          37870      38913    8385930  82  Linux swap / Solaris

Now do a bit of math:
37870 to 38913 inclusive is 1044 cylinders
1044 times 16065 sectors/cylinder divided by 2 sectors/block exactly equals the reported 8385930 so sda2 consists of whole cylinders.

Do the same for sda1 and you get 304182742.5 blocks, so 31.5 blocks (63 sectors) are missing. The size of sda1 is one track less than the total size of the reported range of cylinders. So in this example the first 63 sectors of sda are not part of sda1. The 64'th sector of sda is the 1'st sector of sda1.

miros84 10-28-2010 07:57 AM

Oo, johnsfine, you understund very well hdd stuff. Thank you very much for explain that to me. :)

So, when I install Debian in sda1, and Windows 7 in sda2, and when I turn on my computer, and I see grub menu, thatīs why because I have:

Grub installed in first 512 bytes in sda which is called MBR. In the very begining in the HDD. Or meybe in the first 63 sectors.
Then in the first 512 bytes of sda1, which is the 64th sector I have volume boot record for Debian and in the first 512 bytes of sda2 I have the volume boot record for Windows 7.

Is that right what I understund?

johnsfine 10-28-2010 08:31 AM

Quote:

Originally Posted by miros84 (Post 4142164)
Grub installed in first 512 bytes in sda which is called MBR. In the very begining in the HDD. Or meybe in the first 63 sectors.

No, just a simple first stage loader for grub is in the mbr. Most of grub is in files on sda1, normally in the /boot/grub directory.

Quote:

Then in the first 512 bytes of sda1, which is the 64th sector I have volume boot record for Debian
I think that sector would be unused.

Quote:

and in the first 512 bytes of sda2 I have the volume boot record for Windows 7.
That sector contains a simple loader for what in XP was named NTLDR. I'm not sure what it is named in Windows 7. But in any case, the Windows partition boot sector is a simple loader that starts the process of loading the main loader, just as your MBR contains a simple loader that starts the process of loading grub.

miros84 10-28-2010 11:40 AM

Ok, letīs see. I think I start to understand it.
In a HDD with sda1 - Debian, sda2 Windows 7 and grub installed as main boot manager.
When computer load flash Bios, and Bios load MBR, first are loaded the first 512 bytes in sda, which load grub, which shows me all SO on menu.lst. So, when I choose windows 7 or windows xp from the list, grub load the first 512 bytes from sda2, which load windows xp or windows 7 loader.
Is all this correct?

johnsfine 10-28-2010 11:59 AM

I think that is all correct.

There are some details (intermediate stage loaders) missing from that description, but I don't really know those details either. At the level at which you just described the process, your description is correct.

miros84 10-29-2010 08:40 AM

Hello
I have a hdd with several partitions.
sda1 - debian
sda2 - windows xp
sda3 - win 7
sda4 - ubuntu

I know how to mount each partition, but what I want is to mount sda, not sda1 or sda3. Just sda.
So later, I want to make a copy of MBR of sda.
As I know first 512 bytes from sda1 are not the same like first 512 bytes from sda.
Thatīs why I want to mount sda and with dd, copy the first 512 bytes.
The problem is how to mount sda, if some partition are ntfs and other are ext3?

GrapefruiTgirl 10-29-2010 08:47 AM

You cannot mount the entire drive all at once, but it's OK, because you do not need to do so in order to make a copy of the MBR using dd.

miros84 10-29-2010 09:46 AM

I tried dd if=/dev/sda and it works


All times are GMT -5. The time now is 08:38 PM.