Enabling GRUB to automatically boot from the kernel
Asked Answered
A

2

12

I am developing a kernel for an operating system. In order to execute it, I've decided to use GRUB. Currently, I have a script attached to GRUB's stage1, stage2, a pad file and the kernel itself together which makes it bootable. The only problem is that when I run it, you have to let GRUB know where the kernel is and how big it is manually and then boot it, like this:

kernel 200+KERNELSIZE
boot

KERNELSIZE is the size of the kernel in blocks. This is fine and alright for a start, but is it possible to get these values in the binary and make GRUB boot the kernel automatically? Any suggestions on how to accomplish that?

Adhesion answered 19/10, 2008 at 1:31 Comment(3)
The conventional approach is to put your kernel itself on a filesystem grub can read; any particular reason you aren't doing that?Proximal
I agree with Charles here. Put your OS an existing file system until your OS has a file system of its own.Extravehicular
Well, for testing, we have the final binary (including GRUB) as a file on disk to be used in an emulator. How would I make a disk image that has a filesystem on it?Banna
C
2

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.

Corum answered 20/10, 2008 at 4:13 Comment(1)
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.Banna
M
3

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.

Mousse answered 20/10, 2008 at 4:20 Comment(0)
C
2

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.

Corum answered 20/10, 2008 at 4:13 Comment(1)
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.Banna

© 2022 - 2024 — McMap. All rights reserved.