A New method to bootloader your OS using a extended GRUB2

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
Post Reply
neoe
Posts: 17
Joined: Wed Sep 24, 2014 10:03 am

A New method to bootloader your OS using a extended GRUB2

Post 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.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: A New method to bootloader your OS using a extended GRUB

Post by Kevin »

What is the advantage compared to Multiboot?
Developer of tyndur - community OS of Lowlevel (German)
User avatar
SoLDMG
Member
Member
Posts: 96
Joined: Wed Jul 23, 2014 8:00 am
Location: The Netherlands
Contact:

Re: A New method to bootloader your OS using a extended GRUB

Post 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.
My post is up there, not down here.
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: A New method to bootloader your OS using a extended GRUB

Post 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?
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
neoe
Posts: 17
Joined: Wed Sep 24, 2014 10:03 am

Re: A New method to bootloader your OS using a extended GRUB

Post 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.
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: A New method to bootloader your OS using a extended GRUB

Post 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?
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
neoe
Posts: 17
Joined: Wed Sep 24, 2014 10:03 am

Re: A New method to bootloader your OS using a extended GRUB

Post 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 :lol: , 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.
neoe
Posts: 17
Joined: Wed Sep 24, 2014 10:03 am

Re: A New method to bootloader your OS using a extended GRUB

Post 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.
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: A New method to bootloader your OS using a extended GRUB

Post 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.)
User avatar
SoLDMG
Member
Member
Posts: 96
Joined: Wed Jul 23, 2014 8:00 am
Location: The Netherlands
Contact:

Re: A New method to bootloader your OS using a extended GRUB

Post 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.
My post is up there, not down here.
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: A New method to bootloader your OS using a extended GRUB

Post 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.
User avatar
SoLDMG
Member
Member
Posts: 96
Joined: Wed Jul 23, 2014 8:00 am
Location: The Netherlands
Contact:

Re: A New method to bootloader your OS using a extended GRUB

Post 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.
My post is up there, not down here.
Post Reply