Wednesday, September 10, 2014

Load your OS kernel by Grub2 in a single file.



BIOS loads MBR in 512 bytes into memory 0000h:7c00h

But grub2 can load a whole file into memory 0000h:7c00h,(with a patch)
that means you can write your hobbist OS in one single file.
In this way, maybe other existing OS can be loaded easily.

in grub1 there is command "kernel=file" but I cannot find it in grub2.
grub2 has command linux16, but has other restriction about the format.
grub2 also provides command multiboot, but also spec condition should be met.

The method mentioned here, need only one condition is, the last 2 bytes of first 512 bytes
should be hex 55AA.

and the kernel file could be put in any existing filesystem can be recognized by grub2.

eg:
menuentry 'NEOS on vfat' {
    insmod chain
    insmod fat
    set root='hd0,msdos4'
    chainloader /neoskern
}
or:
menuentry 'NEOS on ext4' {
    insmod part_msdos
    insmod chain
    insmod ext2
   
    set root='hd0,msdos7'
    chainloader /boot/neoskern
}

the patch info is here: http://savannah.gnu.org/bugs/?43184

No comments:

Post a Comment