Unable to create bootable iso using mkiosfs

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
hbaruas
Posts: 2
Joined: Sat Sep 04, 2010 2:09 am

Unable to create bootable iso using mkiosfs

Post 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
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Unable to create bootable iso using mkiosfs

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Unable to create bootable iso using mkiosfs

Post 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.
If you have seen bad English in my words, tell me what's wrong, please.
hbaruas
Posts: 2
Joined: Sat Sep 04, 2010 2:09 am

Re: Unable to create bootable iso using mkiosfs

Post 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?
Post Reply