Page 1 of 1
How to go about writing an OS and bootloader to disk?
Posted: Thu May 11, 2017 4:43 am
by chronium
Hello everyone.
So, after I get myself an ATA driver or something to be able to read and and write to and from the disk, how exactly do I go about writing things like the MBR, a bootloader and my kernel to the disk?
The bootloader I'm aiming for is GRUB2, on normal BIOS.
I do not exactly understand how they all fit together, what needs to get written where, things like that.
And another question, is there a way for me to write a GRUB2 module for my own file system?
Cheers,
Chronium.
Re: Writing an OS and bootloader to disk.
Posted: Thu May 11, 2017 4:49 am
by dozniak
chronium wrote:Hello everyone.
So, after I get myself an ATA driver or something to be able to read and and write to and from the disk, how exactly do I go about writing things like the MBR, a bootloader and my kernel to the disk?
grub-install does grub installation for you, just give it a drive specification (hd0) etc - see GRUB manual for that, it's all detailed there.
chronium wrote:
I do not exactly understand how they all fit together, what needs to get written where, things like that.
If you're using grub, you can write the kernel anywhere on a fileystem that is understood by grub.
chronium wrote:
And another question, is there a way for me to write a GRUB2 module for my own file system?
Yes, it is possible. Get grub sources
https://www.gnu.org/software/grub/grub-download.html and look for implementation of filesystem modules, it's fairly straightforward. E.g. grub-core/fs/fat.c defines a FAT filesystem driver.
Re: How to go about writing an OS and bootloader to disk?
Posted: Thu May 11, 2017 7:58 am
by chronium
I don't want to install it using external tools. I'm interested on how to do the installation from inside my kernel. There should be a way to get the stage 1 and 2 files, write the stage 1 where it should be and then do the rest for stage 2, but that's what I don't quite get how to do.
Where exactly each part of the bootloader should go
Re: How to go about writing an OS and bootloader to disk?
Posted: Thu May 11, 2017 8:01 am
by Geri
the first ,,stage'' goes to the first sector.
the second goes
Re: How to go about writing an OS and bootloader to disk?
Posted: Thu May 11, 2017 9:33 am
by dozniak
chronium wrote:
Where exactly each part of the bootloader should go
You can inspect the sources of grub-install and figure where, how and why it is written.
Learn to read already.