views:

601

answers:

3

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.

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.

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.

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)

Thanks!

+4  A: 

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.

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

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.

DrJokepu
...oooh, I never thought of USB. I'll search around for that.
Nicholas Flynt
Not all computers can boot off of a USB device, but most (all?) modern should.
senfo
senfo: True, not all computers can boot off of USB device, just like not all computers can boot off of a CD-ROM drive. But if it doesn't have a floppy drive, it is probably recent enough to be able to do so.
DrJokepu
I've seen lots of computers that can boot from a CD and not a USB drive, even those with no floppy drive. It would make sense that CD is easier to do. Those specs are useful though, maybe I can generate the info to satisfy the spec on my own.
Nicholas Flynt
In most BIOS:es there is an option called "USB Legacy Support" which will emulate INT13h when booting from an USB stick. But note that this can be a real horror since the USB Legacy Support is implemented using SMM/SMI. Especially if you have your own USB implementation in your OS.
Jonas Gulle
+1  A: 

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.

codelogic
+5  A: 

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.

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.

Nicholas Flynt