如何以编程方式创建可引导CD?

时间:2021-10-06 22:36:48

I'm using a barebones tutorial as the basis for an OS I'm working on, and it seems to be an older tutorial: it has be compiling the kernel down to a floppy image, and then loading it with GRUB.

我正在使用准系统教程作为我正在研究的操作系统的基础,它似乎是一个较旧的教程:它将内核编译为软盘映像,然后使用GRUB加载它。

Basically, I still want to use GRUB, but I'd like to have my OS run from a CD instead. The main reason is that I don't actually have a real floppy drive available (I'm testing in VirtualBox currently) and I thus have no way to test my OS on real hardware.

基本上,我仍然想使用GRUB,但我想让我的操作系统从CD运行。主要原因是我实际上没有可用的真正软盘驱动器(我目前在VirtualBox中测试),因此我无法在真实硬件上测试我的操作系统。

I've been poking around on the net, and I can find lots of utilities that create a bootable CD from a floppy image, but these all seem to require an actual floppy drive, plus it's not really what I'm looking for. I'd like to be able to end up with a bootable CD during my make step ideally, without needing to first place the image on a floppy, which seems rather pointless.

我一直在网上闲逛,我可以找到许多从软盘映像创建可引导CD的工具,但这些似乎都需要一个真正的软盘驱动器,而且它并不是我真正想要的。我希望能够在我的制作步骤中最终获得可引导CD,而不需要先将图像放在软盘上,这似乎毫无意义。

I guess the easy way to answer this: How do I set up GRUB to read my kernel image from a CD? Will I need a special utility to do this from Windows? (The kernel can't compile itself yet, that's not for a looong while)

我想回答这个问题的简单方法是:如何设置GRUB以从CD读取我的内核映像?我是否需要一个特殊的工具来从Windows执行此操作? (内核无法编译自己,这不适用于looong)

Thanks!

3 个解决方案

#1


I found the solution for my project on my own, with some advice from the folks over at OSdev. There is a utility called mkisofs (which can run under Windows using a cygwin dll) that takes a directory, and makes that directory into an ISO image that can be burned to a CD. Using the -b flag, you can specify which file should reside in the boot sector of the disk.

我自己找到了我的项目的解决方案,并得到了OSdev的一些建议。有一个名为mkisofs的实用程序(可以在Windows下使用cygwin dll运行),它接受一个目录,并将该目录转换为可以刻录到CD的ISO映像。使用-b标志,可以指定哪个文件应驻留在磁盘的引导扇区中。

The solution is just to have GRUB in the bootsector, and use GRUB to load the kernel image, which I can compile out in non-floppy form easily.

解决方案只是在引导程序中使用GRUB,并使用GRUB加载内核映像,我可以轻松地以非软盘形式编译。

#2


AFAIK a bootable CD is pretty much the same as a bootable floppy. You need to put the boot loader (GRUB) into the boot sector etc., the BIOS will take care of the low level stuff until you switch to protected mode.

AFAIK可引导CD与可引导软盘几乎相同。您需要将引导加载程序(GRUB)放入引导扇区等,BIOS将处理低级别的东西,直到您切换到保护模式。

You will probably have to make your image and then dd it to the actual physical disk.

您可能需要制作图像,然后将其转换为实际的物理磁盘。

Here's the El Torito Bootable CD specification: http://www.phoenix.com/NR/rdonlyres/98D3219C-9CC9-4DF5-B496-A286D893E36A/0/specscdrom.pdf

这是El Torito可引导CD规范:http://www.phoenix.com/NR/rdonlyres/98D3219C-9CC9-4DF5-B496-A286D893E36A/0/specscdrom.pdf

EDIT: An alternative way to test your kernel would be a bootable USB stick. Again, the BIOS will take care of the low level USB stuff until you turn on A20 and jump to protected mode.

编辑:测试内核的另一种方法是可启动的USB记忆棒。同样,BIOS将处理低级别的USB内容,直到您打开A20并跳转到保护模式。

#3


If you're interested in looking at code, then the Moblin Image Creator is probably a good application to check out. It's written in python and can create different types of bootable images (CD, USB and NAND) for both Live and installable configurations of Moblin Linux.

如果您对查看代码感兴趣,那么Moblin Image Creator可能是一个很好的应用程序。它是用python编写的,可以为Moblin Linux的Live和可安装配置创建不同类型的可引导映像(CD,USB和NAND)。

#1


I found the solution for my project on my own, with some advice from the folks over at OSdev. There is a utility called mkisofs (which can run under Windows using a cygwin dll) that takes a directory, and makes that directory into an ISO image that can be burned to a CD. Using the -b flag, you can specify which file should reside in the boot sector of the disk.

我自己找到了我的项目的解决方案,并得到了OSdev的一些建议。有一个名为mkisofs的实用程序(可以在Windows下使用cygwin dll运行),它接受一个目录,并将该目录转换为可以刻录到CD的ISO映像。使用-b标志,可以指定哪个文件应驻留在磁盘的引导扇区中。

The solution is just to have GRUB in the bootsector, and use GRUB to load the kernel image, which I can compile out in non-floppy form easily.

解决方案只是在引导程序中使用GRUB,并使用GRUB加载内核映像,我可以轻松地以非软盘形式编译。

#2


AFAIK a bootable CD is pretty much the same as a bootable floppy. You need to put the boot loader (GRUB) into the boot sector etc., the BIOS will take care of the low level stuff until you switch to protected mode.

AFAIK可引导CD与可引导软盘几乎相同。您需要将引导加载程序(GRUB)放入引导扇区等,BIOS将处理低级别的东西,直到您切换到保护模式。

You will probably have to make your image and then dd it to the actual physical disk.

您可能需要制作图像,然后将其转换为实际的物理磁盘。

Here's the El Torito Bootable CD specification: http://www.phoenix.com/NR/rdonlyres/98D3219C-9CC9-4DF5-B496-A286D893E36A/0/specscdrom.pdf

这是El Torito可引导CD规范:http://www.phoenix.com/NR/rdonlyres/98D3219C-9CC9-4DF5-B496-A286D893E36A/0/specscdrom.pdf

EDIT: An alternative way to test your kernel would be a bootable USB stick. Again, the BIOS will take care of the low level USB stuff until you turn on A20 and jump to protected mode.

编辑:测试内核的另一种方法是可启动的USB记忆棒。同样,BIOS将处理低级别的USB内容,直到您打开A20并跳转到保护模式。

#3


If you're interested in looking at code, then the Moblin Image Creator is probably a good application to check out. It's written in python and can create different types of bootable images (CD, USB and NAND) for both Live and installable configurations of Moblin Linux.

如果您对查看代码感兴趣,那么Moblin Image Creator可能是一个很好的应用程序。它是用python编写的,可以为Moblin Linux的Live和可安装配置创建不同类型的可引导映像(CD,USB和NAND)。