crebootgrub

Change GRUB's variable using a C language


I was wondering if there is any way for me to write a C program to change the value off GRUB's variables.

I need to write a program that can reboot my computer on another OS, for example:

program changes GRUB's variable and reboot automatically.

I would like to access variables like : title, root, kernel, initrd. But without editing the /boot/grub/menu.lst or grub.conf file.

Is there an API for GRUB?


Solution

  • Why re-invent the wheel? Have a look at grub-set-default. This little tool set the default entry in the grub.cfg on the command line. This is just a little shellscript, but it should be enough for your needs.