Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling GRUB to automatically boot from the kernel

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?

like image 538
Cristián Romo Avatar asked Oct 19 '08 01:10

Cristián Romo


People also ask

How do I set the default grub kernel?

As mentioned in the comments, you can set the default kernel to boot into using the grub-set-default X command, where X is the number of the kernel you want to boot into. In some distributions you can also set this number by editing the /etc/default/grub file and setting GRUB_DEFAULT=X , and then running update-grub .

How do I change the default GRUB boot in Linux?

By default, grub will boot item 0. Thus to change the boot order, you need to define the number of items you want to boot by default in the grub configuration file /etc/default/grub.

How do I boot from grub prompt?

Booting From grub> The first line sets the partition that the root filesystem is on. The second line tells GRUB the location of the kernel you want to use. Start typing /boot/vmli , and then use tab-completion to fill in the rest. Type root=/dev/sdX to set the location of the root filesystem.


1 Answers

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.

like image 134
user29480 Avatar answered Oct 06 '22 19:10

user29480