Change GRUB's variable using a C language [closed]

喜夏-厌秋 提交于 2019-12-04 05:48:14

问题


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 :

  • I am on Suse disk1

program changes GRUB's variable and reboot automatically.

  • I am on Suse disk2

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?


回答1:


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.



来源:https://stackoverflow.com/questions/6490006/change-grubs-variable-using-a-c-language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!