如何制作可加载内核(.elf)的可引导光盘(.iso) [英] How to make a bootable disc (.iso) that loads a kernel (.elf)

查看:350
本文介绍了如何制作可加载内核(.elf)的可引导光盘(.iso)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经制作了一个非常基本的内核,我想制作一个可加载内核的可引导光盘映像.我试图将内核从.elf转换为.bin转换为.iso,但是这导致了不可引导的光盘映像.当我尝试将光盘映像加载到virtualbox或qemu时,它会通知我光盘映像为原始格式,无法加载.

I have made a very basic kernel and I want to make a bootable disc image that loads the kernel. I have tried to convert the kernel from .elf to .bin to .iso, but this has resulted in a non-bootable disc image. When I try to load the disc image into virtualbox or qemu, it notifies me that the disc image is in raw format and fails to load.

我使用objcopy -O binary kernel.elf kernel.bin.elf转换为.bin,然后尝试使用poweriso,winiso和magiciso等转换器将其转换为.iso.转换失败或创建了无法引导的光盘映像.

I converted from .elf to .bin using objcopy -O binary kernel.elf kernel.bin and then attempted to convert to .iso using converters like poweriso, winiso and magiciso. The conversion either failed or created a non-bootable disc image.

如何制作可加载内核的可引导光盘映像.如果需要引导加载程序,我宁愿使用仅用于启动内核的最少代码制作一个自定义引导程序.

How do I make a bootable disc image that loads my kernel. If a bootloader is required, I would prefer to make a custom one with very minimal code designed only to start my kernel.

推荐答案

还有很多其他功能,只需将内核文件转换为二进制文件并将其放置在ISO光盘(图像)上即可.

There is a lot more to it that just converting your kernel file to binary and placing it on an ISO disc (image).

您需要某种引导加载程序.如果以旧版BIOS机器引导,则需要一个引导加载程序,该加载程序可以理解ISO文件系统,找到该文件,然后将内核文件读取到内存中.已经有了一些,Grub浮现在脑海.

You need to have a boot loader of some kind. If you boot as a legacy BIOS machine, you will need a boot loader that understands the ISO file system, finding, then reading the kernel file into memory. There are a few already made, Grub comes to mind.

由于您要创建自己的文件(我对此表示赞赏),因此您需要阅读ISO文件系统在磁盘上的存储方式,BIOS如何为您加载一个或多个扇区等.

Since you want to create your own (and I commend you on that), you will need to read up on how the ISO file system is stored on the disc, how the BIOS will load one or more sectors for you, etc.

例如,BIOS将使用不同的方法从光盘加载一个或多个扇区.一种可能是软盘仿真,另一种可能是硬盘仿真,而另一种可能是直接读取ISO磁盘扇区.

For example, the BIOS will load one or more sectors from the disc using different methods. One would be floppy emulation, another could be hard drive emulation, while another could be direct ISO disc sector reads.

我建议您不要以ISO开头.从软盘映像开始,甚至更好的是从硬盘驱动器映像开始.然后,您要做的就是编写一个引导区和使用BIOS读取磁盘服务的加载程序.这要容易得多.

I would suggest that you don't start with ISO. Start with a floppy image or even better, a hard drive image. Then all you have to do is write a boot sector and loader that uses the BIOS read disk services. This is much easier.

但是,不要误会我的意思,仍然有很多工作要做.

However, don't get me wrong, there is still a lot of work to do this.

如果您希望跳过所有这些操作,则可以将内核编写为(Win)PE文件,并使用较新的固件(UEFI)为您加载它. EFI将使用具有一个或多个FAT卷的GPT格式的驱动器,并将为您查找并加载您的PE格式的可执行文件.

If you wish to skip all of that, you can write your kernel as a (Win) PE file and use the newer firmware (UEFI) to load it for you. EFI will use a GPT formatted drive with one or more FAT volumes and will find and load your PE formatted executable for you.

但是,有些人可能会不同意,但是由于您是作为学习经验来做这个项目的,所以我建议您采用传统BIOS路线.这将使您了解有关计算机如何启动,加载第一条指令等的更多信息.

However, and some may disagree, but since you are doing this project as a learning experience, I suggest you take the Legacy BIOS route. This will let you learn a lot more about how a computer boots up, loads the first instructions, etc.

对于旧版BIOS软盘或硬盘驱动器路由,请搜索引导扇区以及软盘或硬盘驱动器.这将向您展示一些人是如何完成任务的.该引导扇区通常会加载另一个文件,即OS加载程序.然后,该加载器用于加载内核和(可能)其他文件,并在跳转到内核之前设置必要的项目.

For the Legacy BIOS floppy or hard drive route, do a search for boot sectors and either floppy or hard drive. This will show you how some have accomplished the task. This boot sector usually loads another file which is the OS loader. This loader is then used to load the kernel and (possibly) other files, setting up the necessary items before jumping to the kernel.

如果您愿意,我已经写了几本关于该主题的书,展示了如何为软盘,硬盘驱动器以及ISO光盘映像写入启动扇区.我还从早期版本中包含示例源代码.

If you wish, I have written a few books on this subject, showing how to write boot sectors for floppies, hard drives, as well as ISO disc images. I also have included example source code from an earlier version.

这篇关于如何制作可加载内核(.elf)的可引导光盘(.iso)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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