Can we fake a Hard Drive master boot record
Can we fake a Hard Drive master boot record
I was looking at examples of hard drive MBR (Master Boot Record) and just wondering if we can fake it. I want to make a hard drive MBR to just print 2 linex of value. I know that you can do this with a floppy disk but on hard drive you have to make a partition parameter table and make sure that the partition boot indicator = 0x80.Have you got any ideas how can i go about it
Re: Can we fake a Hard Drive master boot record
For what it's worth, Bochs boots from HDD images with just a typical boot sector at sector 0. I don't know if that's correct and if a real BIOS would like that, but it works for me in Bochs. No need for all of the partition table stuff or anything, just have the signature at the end and it doesn't seem to care.
-
- Member
- Posts: 204
- Joined: Thu Apr 12, 2007 8:15 am
- Location: Michigan
Re: Can we fake a Hard Drive master boot record
You can use the first sector of the hard drive however you like.
You only need a valid partition table if you want your code to be compliant with other standards (i.e, if you were writing a multi bootloader or you want your OS to work alongside other OSs without much trouble, etc), but it sounds like you just want to experiment. In this case, you can use the hard drive as if it were a floppy (the difference wouldn't be important for simply printing to the screen).
You can also do the same thing with a partition, where the partition exists in the partition table with the bootable flag set, and the first 512 bytes of the partition contain your bootloader (not sure if it's really required, but you should be able to spare the last two bytes for a boot signature 0x55 0xAA). This is, assuming you have a properly configured bootloader program in the MBR as well (set to chainload your partition).
You only need a valid partition table if you want your code to be compliant with other standards (i.e, if you were writing a multi bootloader or you want your OS to work alongside other OSs without much trouble, etc), but it sounds like you just want to experiment. In this case, you can use the hard drive as if it were a floppy (the difference wouldn't be important for simply printing to the screen).
You can also do the same thing with a partition, where the partition exists in the partition table with the bootable flag set, and the first 512 bytes of the partition contain your bootloader (not sure if it's really required, but you should be able to spare the last two bytes for a boot signature 0x55 0xAA). This is, assuming you have a properly configured bootloader program in the MBR as well (set to chainload your partition).
Some people are offended by the verifiable truth; such people tend to remain blissfully unencumbered by fact.
If you are one of these people, my posts may cause considerable discomfort. Read at your own risk.
If you are one of these people, my posts may cause considerable discomfort. Read at your own risk.
Re: Can we fake a Hard Drive master boot record
Thanks!
Ok! I just want to know if i Can not use a valid partition table at all. Does it allow me to do that? Have a look at my patricknet source code. I want to copy exact and run correctly on my hard drive?
REMOVED LINK!
well that is a load of crap becasue i already try that.Telgin wrote: No need for all of the partition table stuff or anything, just have the signature at the end and it doesn't seem to care.
Ok! I just want to know if i Can not use a valid partition table at all. Does it allow me to do that? Have a look at my patricknet source code. I want to copy exact and run correctly on my hard drive?
REMOVED LINK!
Last edited by PatrickV on Fri Jul 10, 2015 7:58 pm, edited 1 time in total.
Re: Can we fake a Hard Drive master boot record
Hi,
In any case, when you tried it what went wrong?
Cheers,
Brendan
That *is* correct - the BIOS and hardware doesn't know or care about the partition table, and just loads the first sector and runs it (if the BIOS determines the first sector is bootable, etc). The first sector is usually an MBR that scans it's partition table and chainloads the boot sector in the active partition, but it doesn't have to. In a similar way you can have a partition table and MBR in a floppy if you like (but that's much less standard - other OS's probably won't recognize it).PatrickV wrote:well that is a load of crap becasue i already try that.Telgin wrote: No need for all of the partition table stuff or anything, just have the signature at the end and it doesn't seem to care.
In any case, when you tried it what went wrong?
I took a quick look at your source code, and it's dodgy - the magic number is in the wrong place. To fix it, replace "padding times 348 db 0" with "padding times 349 db 0" (which should work, but is still silly) or "padding times ($$-$+0x1FE) db 0x00" (which lets you modify the code without needing to manually recalculate how much padding to use).PatrickV wrote:I want to copy exact and run correctly on my hard drive?
http://www.patricknet.pvcomputers.co.nz
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: Can we fake a Hard Drive master boot record
That is an old verson. I was using that for an example. I've already fixed it in Beta 0.0.2 which i am having problems completing it.