Page 1 of 1
A New method to bootloader your OS using a extended GRUB2
Posted: Wed Sep 24, 2014 10:23 am
by neoe
This method just added a command to grub2 (safe to replace the current version of grub2)
* Your kernel file can be located in any existing filesystem(because Grub can find it out).
* The bootloader read the specified kernel(a single file) into memory at a specified location and start to run it from the first byte.
* You don't need to break your harddisk structure by making new partitions.
* You probably don't need to break your current boot method if you develop on linux, because grub2 is the default bootloader for most of Linux distro.
example grub.cfg
menuentry "YourOS" {
insmod part_msdos
insmod ext2
set root='hd0,msdos7'
osimg /boot/youros.bin 0x7c00
}
It is open sourced, check it out from:
https://github.com/neoedmund/grub-2.0.0/tree/osimg
Feel free to leave a comment.
Re: A New method to bootloader your OS using a extended GRUB
Posted: Wed Sep 24, 2014 1:16 pm
by Kevin
What is the advantage compared to Multiboot?
Re: A New method to bootloader your OS using a extended GRUB
Posted: Wed Sep 24, 2014 1:25 pm
by SoLDMG
OSDeving on Windows just became a hell of a lot easier. Darn you PE-only GCC which refuses to compile for ELF as target and TCC not having ELF support on Windows.
Thank you, sir.
Re: A New method to bootloader your OS using a extended GRUB
Posted: Wed Sep 24, 2014 2:15 pm
by Roman
neoe wrote:This method just added a command to grub2 (safe to replace the current version of grub2)
* Your kernel file can be located in any existing filesystem(because Grub can find it out).
* The bootloader read the specified kernel(a single file) into memory at a specified location and start to run it from the first byte.
* You don't need to break your harddisk structure by making new partitions.
* You probably don't need to break your current boot method if you develop on linux, because grub2 is the default bootloader for most of Linux distro.
example grub.cfg
menuentry "YourOS" {
insmod part_msdos
insmod ext2
set root='hd0,msdos7'
osimg /boot/youros.bin 0x7c00
}
It is open sourced, check it out from:
https://github.com/neoedmund/grub-2.0.0/tree/osimg
Feel free to leave a comment.
Does it emulate a disk like memdisk from syslinux?
Re: A New method to bootloader your OS using a extended GRUB
Posted: Wed Sep 24, 2014 3:00 pm
by neoe
Kevin wrote:What is the advantage compared to Multiboot?
They both make things easy by load kernel by file in filesystem instead of raw sectors on disk.
The difference is, Multiboot, has a header format to fill and an information structure to read. To use it you must read and implements the spec which has about 64k letters.
Using "osimg", you don't bother to know there is a Multiboot on the earth.
But of course you should know bootsector, because it is the really thing works, you cannot pass it.
If you know bootsector, you know "osimg", no more concept, just variable changed, not 1 sector but 1 file, not 0x7c00 but anywhere you specify.
In one word, save your brain.
Re: A New method to bootloader your OS using a extended GRUB
Posted: Wed Sep 24, 2014 3:07 pm
by Roman
neoe wrote:Kevin wrote:What is the advantage compared to Multiboot?
They both make things easy by load kernel by file in filesystem instead of raw sectors on disk.
The difference is, Multiboot, has a header format to fill and an information structure to read. To use it you must read and implements the spec which has about 64k letters.
Using "osimg", you don't bother to know there is a Multiboot on the earth.
But of course you should know bootsector, because it is the really thing works, you cannot pass it.
If you know bootsector, you know "osimg", no more concept, just variable changed, not 1 sector but 1 file, not 0x7c00 but anywhere you specify.
In one word, save your brain.
Why not to create a small partition and use GRUB's chainloader?
Re: A New method to bootloader your OS using a extended GRUB
Posted: Wed Sep 24, 2014 3:13 pm
by neoe
Roman wrote:neoe wrote:This method just added a command to grub2 (safe to replace the current version of grub2)
* Your kernel file can be located in any existing filesystem(because Grub can find it out).
* The bootloader read the specified kernel(a single file) into memory at a specified location and start to run it from the first byte.
* You don't need to break your harddisk structure by making new partitions.
* You probably don't need to break your current boot method if you develop on linux, because grub2 is the default bootloader for most of Linux distro.
example grub.cfg
menuentry "YourOS" {
insmod part_msdos
insmod ext2
set root='hd0,msdos7'
osimg /boot/youros.bin 0x7c00
}
It is open sourced, check it out from:
https://github.com/neoedmund/grub-2.0.0/tree/osimg
Feel free to leave a comment.
Does it emulate a disk like memdisk from syslinux?
It's Not. I don't know it until read your post
, memdisk from syslinux hooks INT 13h and INT 15h to emulate a disk as if it really exists.
"osimg" use grub2 to read file to memory location and execute from there.
Different approach, should be used in different conditions, see which works, which fit your needs better.
Re: A New method to bootloader your OS using a extended GRUB
Posted: Wed Sep 24, 2014 3:29 pm
by neoe
Roman wrote:neoe wrote:Kevin wrote:What is the advantage compared to Multiboot?
They both make things easy by load kernel by file in filesystem instead of raw sectors on disk.
The difference is, Multiboot, has a header format to fill and an information structure to read. To use it you must read and implements the spec which has about 64k letters.
Using "osimg", you don't bother to know there is a Multiboot on the earth.
But of course you should know bootsector, because it is the really thing works, you cannot pass it.
If you know bootsector, you know "osimg", no more concept, just variable changed, not 1 sector but 1 file, not 0x7c00 but anywhere you specify.
In one word, save your brain.
Why not to create a small partition and use GRUB's chainloader?
* Chainloader only read 512 bytes(as far as I read the grub code) and verifies a 55AA signature. You need to load next stages using INT13 or something.
* If the partition is not the beginning of a disk, you need to find out where is it.
* When you use partition, you need to use "dd" or something, which is a little dangerous, if used it wrong, may destroy an existing filesystem.
Instead, using "osimg", It's done when the kernel image is generated on your develop environment. you don't need further steps to copy it around or "dd" it to somewhere.
Re: A New method to bootloader your OS using a extended GRUB
Posted: Thu Sep 25, 2014 1:21 am
by Octocontrabass
SoLDMG wrote:PE-only GCC which refuses to compile for ELF as target
It sounds like you're not using a
cross-compiler. If you install MSYS, you can use the MSYS shell and follow
the wiki's instructions to build your cross-compiler.
(For my toolchain, I installed MSYS/GCC using the instructions
here.)
Re: A New method to bootloader your OS using a extended GRUB
Posted: Thu Sep 25, 2014 4:19 am
by SoLDMG
Octocontrabass wrote:SoLDMG wrote:PE-only GCC which refuses to compile for ELF as target
It sounds like you're not using a
cross-compiler. If you install MSYS, you can use the MSYS shell and follow
the wiki's instructions to build your cross-compiler.
(For my toolchain, I installed MSYS/GCC using the instructions
here.)
That's not what I meant. I tried to compile GCC with ELF as the target (a crosscompiler) but for some reason it errors some random error. I use a VM with Debian for ELF compiling and then sync the ELF file with Dropbox and use that for testing with GRUB.
Re: A New method to bootloader your OS using a extended GRUB
Posted: Thu Sep 25, 2014 4:54 am
by Octocontrabass
SoLDMG wrote:but for some reason it errors some random error.
If you followed the wiki's instructions and still got an error, please make a thread about it. If the wiki is wrong, I'd like to fix it.
Re: A New method to bootloader your OS using a extended GRUB
Posted: Thu Sep 25, 2014 7:57 am
by SoLDMG
Octocontrabass wrote:SoLDMG wrote:but for some reason it errors some random error.
If you followed the wiki's instructions and still got an error, please make a thread about it. If the wiki is wrong, I'd like to fix it.
I don't know what error it is anymore. I'm working on a different project right now. I'll try it again soon though, and see if I can get it working then.