使用C语言更改GRUB的变量 [英] Change GRUB's variable using a C language

查看:138
本文介绍了使用C语言更改GRUB的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有什么办法让我写一个C程序更改了GRUB的变量的值。

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 :


  • 我在SUSE的disk1

程序更改GRUB的变量,并自动重启。

program changes GRUB's variable and reboot automatically.


  • 我在SUSE磁盘2

我想访问变量一样:标题,根,内核的initrd。但是,如果没有编辑了/boot/grub/menu.lst或grub.conf文件。

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

是否有GRUB的API?

Is there an API for GRUB?

推荐答案

为什么要重新发明轮子?看看平头设置默认。这个小工具设置在的grub.cfg在命令行上的默认项。这只是一个小shellscript里,但它应该是足够满足您的需求。

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.

这篇关于使用C语言更改GRUB的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆