How to programmatically create a bootable CD?

I am using the barebones tutorial as the basis for the operating system I'm working on, and it seems to be an older tutorial: it collects the kernel onto a floppy disk, and then loads it using GRUB.

Basically, I still want to use GRUB, but I would like my OS to start from the CD. The main reason is that I actually do not have a real floppy disk (I am currently testing in VirtualBox), and therefore I have no way to test my OS on real hardware.

I went on the net and I can find many utilities that create a bootable CD from a floppy disk, but for that, everything seems to require an actual floppy drive, and this is not quite what I am looking for. I would like that in the end I could make a bootable CD during my step, without having to first place the image on a floppy disk, which seems pretty pointless.

I think an easy way to answer this question is: How do I configure GRUB to read a kernel image from a CD? Do I need a special utility for Windows? (The kernel cannot compile yet, but not for looong while)

Thanks!

+6
osdev grub
source share
3 answers

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

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

+5
source share

AFAIK bootable CD is pretty much like a bootable floppy disk. You need to put the bootloader (GRUB) in the boot sector, etc., the BIOS will take care of the low-level material until you go into protected mode.

You will probably have to make your image and then dd to a physical disk.

Here is the specification of the El Torito bootable 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 drive. Again, the BIOS will take care of the low-level USB device until you turn on the A20 and go into protected mode.

+4
source share

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

+1
source share

All Articles