LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 02-12-2019, 08:29 PM   #1
ultra_reader
LQ Newbie
 
Registered: Apr 2018
Posts: 22

Rep: Reputation: Disabled
Question 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?

Any clarification will be appreciated!

Thank you!!!
 
Old 02-12-2019, 08:43 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,360
Blog Entries: 28

Rep: Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148
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."

Last edited by frankbell; 02-12-2019 at 08:45 PM.
 
Old 02-12-2019, 08:52 PM   #3
ultra_reader
LQ Newbie
 
Registered: Apr 2018
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by frankbell View Post
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!
 
Old 02-12-2019, 09:24 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,760

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
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.

https://en.wikipedia.org/wiki/GNU_GRUB
 
1 members found this post helpful.
Old 02-13-2019, 12:19 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,145

Rep: Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124
Quote:
Originally Posted by ultra_reader View Post
I know what MBR is and what it contains
Be careful what you think you know ...
Quote:
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.
 
Old 02-13-2019, 12:35 AM   #6
ultra_reader
LQ Newbie
 
Registered: Apr 2018
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
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.

https://en.wikipedia.org/wiki/GNU_GRUB
This!!!

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)

https://learning.oreilly.com/library...52/apas02.html

Last edited by ultra_reader; 02-13-2019 at 12:38 AM.
 
Old 02-13-2019, 03:35 PM   #7
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,914

Rep: Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032
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.

Last edited by GazL; 02-13-2019 at 03:37 PM.
 
2 members found this post helpful.
Old 02-13-2019, 05:48 PM   #8
ultra_reader
LQ Newbie
 
Registered: Apr 2018
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by GazL View Post
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!
 
Old 02-14-2019, 03:57 AM   #9
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,914

Rep: Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032
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.
 
1 members found this post helpful.
Old 02-14-2019, 02:40 PM   #10
ultra_reader
LQ Newbie
 
Registered: Apr 2018
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by GazL View Post
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!!!!


SOLVED!!!!!!!
 
Old 02-14-2019, 03:45 PM   #11
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,914

Rep: Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032Reputation: 5032
You're welcome. Happy booting!
 
  


Reply

Tags
bootstrap, mbr



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] fdisk shows logical sector size smaller than physical sector size? enine Slackware - Installation 5 09-03-2014 11:57 AM
Fdisk shows logical sector size smaller than physical sector size after clonezilla narnie Linux - Hardware 12 07-03-2013 09:01 PM
[SOLVED] How can I make 512byte/sector format on 4KiB/sector drive? delorean-bf Linux - General 14 11-20-2012 09:33 AM
Which program can boot a copy of the MBR (fake MBR) using mbr.bin Xeratul Linux - Software 6 12-03-2010 11:40 PM
"LI" from boot floppy? Can't load XP or Linux. Damaged MBR or boot sector or ...? SparceMatrix Linux - General 10 09-27-2002 01:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration