Page 1 of 1

Unable to create bootable iso using mkiosfs

Posted: Sat Sep 04, 2010 3:33 am
by hbaruas
Hi Friends,

I am new to this forum and OS development. This is my first post.

I am trying to create a bootable iso using mkisofs. I have a working boot code and a small kernel which works fine(in bochs) when I create the image using below code from makefile:

$(V)dd if=/dev/zero of=$(OBJDIR)/kern/bochs.img~ count=10000 2>/dev/null
$(V)dd if=$(OBJDIR)/boot/boot of=$(OBJDIR)/kern/bochs.img~ conv=notrunc 2>/dev/null
$(V)dd if=$(OBJDIR)/kern/kernel of=$(OBJDIR)/kern/bochs.img~ seek=1 conv=notrunc 2>/dev/null
$(V)mv $(OBJDIR)/kern/bochs.img~ $(OBJDIR)/kern/bochs.img

Well this creates a "bochs.img" file, and it works just fine mounted as a hard disk under bochs. My problem is when I try to create the bochs.img as a floppy image file (1.44mb) by replacing first line above by:

$(V)dd if=/dev/zero of=$(OBJDIR)/kern/bochs.img~ bs=512 count=2880 2>/dev/null

rest of the code is same as above, the floppy image does not boot on bochs.

What I want to do is to be able to boot from the floppy image and then use that image to create a bootable iso image which can boot as an emulated floppy. But I guess if the floppy image itself does not boot I will not be able to build an iso which can boot as an emulated floppy.

I tried one more thing, I tried to use my original bochs.img to build a bootable iso file using -hard-disk-boot option in mkisofs but it does not build iso complaining something about the image not having partitions.

Could someone please help me out on this?

Thanks

Re: Unable to create bootable iso using mkiosfs

Posted: Sat Sep 04, 2010 5:02 pm
by Combuster
First off, you have a bootsector that's never going to practically work on real hardware. It doesn't support or provide partitions so it can't properly be used on real disks where it should provide that information, and it probably uses harddisk-specific code because it can't boot from floppy either.

First off, make sure your bootsector works with partitions if you plan on continuing harddisk support. Second, for floppies, stick with int 13h/AH=02h and int 13h/AH=00h (not necessary on bochs, but it is often required on real hardware). Given the difference between the two media, you probably end up with two versions since one sector may be too small to figure out what code to use when.

You can also use or look at an existing bootloader.

Re: Unable to create bootable iso using mkiosfs

Posted: Sat Sep 04, 2010 9:44 pm
by egos
Well this creates a "bochs.img" file, and it works just fine mounted as a hard disk under bochs.
Where has Bochs taken BIOS CHS geometry? I think to have MBR with PT is better.
My problem is when I try to create the bochs.img as a floppy image file (1.44mb) by replacing first line above by:

$(V)dd if=/dev/zero of=$(OBJDIR)/kern/bochs.img~ bs=512 count=2880 2>/dev/null

rest of the code is same as above, the floppy image does not boot on bochs.
What Bochs options did you use? Are you sure that boot code works correctly? Also I have doubts about missing bs parameter where seek=1 is used.

I tried one more thing, I tried to use my original bochs.img to build a bootable iso file using -hard-disk-boot option in mkisofs but it does not build iso complaining something about the image not having partitions.
"El Torito" requires partition table (with one record) for hard disk images.

Re: Unable to create bootable iso using mkiosfs

Posted: Mon Sep 13, 2010 2:12 am
by hbaruas
Thanks for the reply guys. I think i better take a look at an existing bootloader code, before trying my hand at it. Any suggestions for a simple, easy to read bootloader code apart from GRUB?