views:

659

answers:

2

I am currently writing a kernel, and in an attempt to actually run it, I've decided to use GRUB. Currently, we have a script to attach GRUB's stage1, stage2, a pad file, and the actual kernel itself together which makes it bootable. The only problem is that when running it, you have to let GRUB know where the kernel is and how long it is manually and then boot it, like this:

kernel 200+KERNELSIZE
boot

Where KERNELSIZE is the size of the kernel in blocks. This is fine and dandy for a start, but is it possible to get these values in the binary and make GRUB boot the kernel automatically?

+2  A: 

I would imagine you could just make your own menu.lst conf file, load that at the grub shell with "configfile /path/to/menu.lst" and then do "setup (hd0)" replacing values as needed. I'm just guessing though.. no telling what the differences are on your custom setup.

It turns out we were using an old tutorial that told us to it the way we were. We've since taken Charles's advice and moved the bootable image to an ISO.
Cristián Romo
+3  A: 

http://www.gnu.org/software/grub/manual/grub.html#Embedded-data gives some general information about block list storage in GRUB. Most importantly, it mentions that block lists are stored in well defined locations in stage2.

You will probably want to look at the GRUB source code to figure out the exact location.