[SOLVED] Is MBR in the boot block/sector or is MBR the boot block/sector?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is MBR in the boot block/sector or is MBR the boot block/sector?
Hello there.
I know what MBR is and what it contains but I found several references across linux books talk about boot sector/block which exists before block group 0 (ext2/3 layout) and holds data to start the system ----> bootstrap loader.
So now Im having second thoughts about if those references actually mean MBR?
With Linux distros, the boot loader need not necessarily be installed to the MBR, though it often is.
For an example, see this page illustrating a Slackware install and look for the picture labeled "Lilo destination is preferable on Master boot record MBR."
With Linux distros, the boot loader need not necessarily be installed to the MBR, though it often is.
For an example, see this page illustrating a Slackware install and look for the picture labeled "Lilo destination is preferable on Master boot record MBR."
I don't get it. It says option1 and 2 are safest but the guide proceeded with MBR? Ok.
Although It doesn't answer original question, thank you!
Not sure I fully understand the question and it would be nice if you could post a reference but the boot sector code is the first 446 bytes of the MBR which isn't enough space for the entire boot loader code so it is typically split into several stages. Depending on boot loader and version the next stage is sometimes written in the empty space between the end of the MBR and the start of the first partition.
but I found several references across linux books talk about boot sector/block which exists before block group 0 (ext2/3 layout) and holds data to start the system ----> bootstrap loader.
So now Im having second thoughts about if those references actually mean MBR?
Possibly not - partitions can have a boot sector record that can be chainloaded. References to ext? makes this the likely source of confusion. As above, refences will engender more appropriate responses.
Not sure I fully understand the question and it would be nice if you could post a reference but the boot sector code is the first 446 bytes of the MBR which isn't enough space for the entire boot loader code so it is typically split into several stages. Depending on boot loader and version the next stage is sometimes written in the empty space between the end of the MBR and the start of the first partition.
Sorry if I wasn't enough clear the 1st time.
My doubt came from this two extracts from oreilly "how linux kernel works"
Quote:
Ext2 Disk Data Structure
The first block in each Ext2 partition is never managed by the Ext2 filesystem, because it is reserved for the partition boot sector (see Appendix A).
Appendix A:
Quote:
The BIOS bootstrap procedure essentially performs the following four operations:
1,
2,
3: Searches for an operating system to boot. Actually, depending on the BIOS setting, the procedure may try to access (in a predefined, customizable order) the first sector (boot sector) of every floppy disk, hard disk, and CD-ROM in the system.
But later says:
Quote:
Ancient Age: the Boot Loader
The boot loader is the program invoked by the BIOS to load the image of an operating system kernel into RAM. Booting from a hard disk is done differently. The first sector of the hard disk, named the Master Boot Record(MBR), includes the partition table[*] and a small program, which loads the first sector of the partition containing the operating system to be started
Wasn't bootstrap responsible for that last task? Try to access the first sector?
And at the same time the MBR tries to load the first sector as well?
It's confusing!
Here's the book (you can sign up for free trial, I think it's one week or so)
BIOS reads sector 0 of the disk -the Master Boot Record - and loads and runs the Master Bootloader contained within.
Master Bootloader looks in the partition table of the MBR for the first partition that is flagged as active, loads the Partition Boot Record (the first sector of that partition) from that, and runs the Partition Bootloader, which loads the OS.
Now, where it gets interesting is that when you install the linux bootloader you have the choice of overwriting either the Master Bootloader or the Partition Bootloader with either the lilo or grub stage1 bootloader:
If you overwrite the Partition Bootloader, then the Master bootloader will still work as before and start whichever partition bootloader is marked active.
If you overwrite the Partition Bootloader but have never installed the standard Master bootloader -- perhaps a completely new disk with no other OS on it -- then nothing will boot.
If you overwrite the Master bootloader then depending on how they are configured lilo/grub bootloaders can either chain the Partition bootloader, or just load the kernel directly, bypassing the Partition bootloader entirely.
So, in short, if your disk only contains linux, then you might as well install the bootloader to the MBR. If you will be dual booting with something else and your MBR already contains a Master Bootloader, then it might be best to install the linux bootloader to the Partition and mark it as active, but you don't have to.
Now, because the first sector of a partition may contain a bootloader, many, but not all filesystems will ignore the first few sectors of the partition just to be sure that they're not going to clobber it. If I remember rightly XFS isn't one of them and as such is not a suitable choice for a partition holding a bootloader. ext2/3/4 are safe.
Then of course there's EFI which is a whole other can of worms.
BIOS reads sector 0 of the disk -the Master Boot Record - and loads and runs the Master Bootloader contained within.
Master Bootloader looks in the partition table of the MBR for the first partition that is flagged as active, loads the Partition Boot Record (the first sector of that partition) from that, and runs the Partition Bootloader, which loads the OS.
Now, where it gets interesting is that when you install the linux bootloader you have the choice of overwriting either the Master Bootloader or the Partition Bootloader with either the lilo or grub stage1 bootloader:
If you overwrite the Partition Bootloader, then the Master bootloader will still work as before and start whichever partition bootloader is marked active.
If you overwrite the Partition Bootloader but have never installed the standard Master bootloader -- perhaps a completely new disk with no other OS on it -- then nothing will boot.
If you overwrite the Master bootloader then depending on how they are configured lilo/grub bootloaders can either chain the Partition bootloader, or just load the kernel directly, bypassing the Partition bootloader entirely.
So, in short, if your disk only contains linux, then you might as well install the bootloader to the MBR. If you will be dual booting with something else and your MBR already contains a Master Bootloader, then it might be best to install the linux bootloader to the Partition and mark it as active, but you don't have to.
Now, because the first sector of a partition may contain a bootloader, many, but not all filesystems will ignore the first few sectors of the partition just to be sure that they're not going to clobber it. If I remember rightly XFS isn't one of them and as such is not a suitable choice for a partition holding a bootloader. ext2/3/4 are safe.
Then of course there's EFI which is a whole other can of worms.
Hope that helps.
Thanks!!!! This clarified my original doubt!!!!
edit: sorry but what happens in the case of EFI/UEFI? thx!
In EFI the bootloaders are files within the EFI "SYSTEM" partition (which is fat32 formatted). EFI chooses which one to boot from a list it keeps in non-volatile memory.
In EFI the bootloaders are files within the EFI "SYSTEM" partition (which is fat32 formatted). EFI chooses which one to boot from a list it keeps in non-volatile memory.
Thanks a lot @Gazl!!! Your replies helped understand better that part of the boot process which it didn't stuck on my head!!!!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.