OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 9:27 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Partition Boot Record bootstrap code
PostPosted: Tue May 09, 2017 3:46 am 
Offline

Joined: Tue May 09, 2017 2:51 am
Posts: 1
I've read in many sources that Partition Boot Record/Record is written upon formatting a disk partition and contains machine code for bootstrapping specific OS. My question is how a formatting tool like DOS format command can write specific OS bootstrap while it only formats not installs specific OS?


Top
 Profile  
 
 Post subject: Re: Partition Boot Record bootstrap code
PostPosted: Tue May 09, 2017 4:59 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
MBR only contains code to locate a bootable partition and load a bootsector from it. Your specific OS bootloader is located in that partition and does the rest of the job.

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: Partition Boot Record bootstrap code
PostPosted: Tue May 09, 2017 5:04 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
So what happens when grub is installed in the MBR? It has no problem loading an OS kernel located in one of the partitions.

To answer the OP - the DOS format command has the ability to copy the boot code and files for DOS as well as just formatting the disk. But it can't make another OS bootable.


Top
 Profile  
 
 Post subject: Re: Partition Boot Record bootstrap code
PostPosted: Tue May 09, 2017 8:32 am 
Offline
Member
Member

Joined: Tue May 13, 2014 3:02 am
Posts: 280
Location: Private, UK
The "FORMAT /S" MS-DOS command you're talking about doesn't write to the MBR. It writes to the partition's boot record and installs the absolute minimal files that MS-DOS needs to run (IO.SYS, MSDOS.SYS and COMMAND.COM). It does install a minimal version of "the specific OS".

To write the MBR for booting DOS, you'd use "FDISK /MBR" (or just create the partition table in FDISK on a completely blank disk). You can also install the minimal files without formatting using the "SYS" command.

When MS-DOS boots (from a hard drive), the MBR code checks the partition table for a bootable partition. It then transfers control to that partition's boot record, which then loads the aforementioned files. Both of these are about as primitive as it's possible to be; it's even required that IO.SYS be the first file on the partition and not be fragmented. MS-DOS's MBR can (and fairly commonly was, back when DOS was still relevant) be used to boot OSs other than MS-DOS; it's too primitive to care what it's actually loading, as long as it comes from the boot record of a "bootable" partition.

GRUB is a much more advanced bootloader. It's able to read the partition table, understand the filesystem within, load configuration, display a menu and load multiple different kinds of kernel (all this depends on the modules it's been configured with). As a result, it's much larger than the DOS MBR, but thankfully on modern(ish) systems there's (usually) a nearly 1MB "gap" between the MBR/partition table and the first actual partition and this is where GRUB puts most of its code. GRUB's MBR just transfers control to the code in the "gap".

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], SemrushBot [Bot] and 89 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group