使 GRUB 自动从内核启动
我正在为操作系统开发内核。 为了执行它,我决定使用 GRUB。 目前,我有一个脚本附加到 GRUB 的 stage1、stage2、pad 文件和内核本身,这使得它可以启动。 唯一的问题是,当我运行它时,你必须让 GRUB 手动知道内核在哪里以及它有多大,然后启动它,如下所示:
kernel 200+KERNELSIZE boot
KERNELSIZE
是内核的大小(以块为单位) 。 对于开始来说这很好,但是是否可以在二进制文件中获取这些值并使 GRUB 自动引导内核? 关于如何实现这一目标有什么建议吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://www.gnu.org/software/grub/manual/grub.html#Embedded-data< /a> 提供有关 GRUB 中块列表存储的一些常规信息。 最重要的是,它提到阻止列表存储在 stage2 中明确定义的位置。
您可能需要查看 GRUB 源代码来找出确切的位置。
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.
我想您可以制作自己的 menu.lst conf 文件,使用“configfile /path/to/menu.lst”在 grub shell 中加载该文件,然后根据需要执行“setup (hd0)”替换值。 我只是猜测......不知道您的自定义设置有什么差异。
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.