Page 1 of 1
The length of my bootsector
Posted: Fri Apr 25, 2014 2:14 pm
by Isaac
Hi. I'v seen the code of some open source bootsector which is written for ISO 9660. I noticed that the bootsector is 2048 bytes instead of 512. I also noticed that it doesn't have aa55 at the end. I remember reading somewhere that ISO 9660 Bootsectors are different.
Anyway, I'm now trying to write my own ISO 9660 bootsector and it won't run. QEMU says it's not bootable and a real computer just does nothing. Why not?
Re: The length of my bootsector
Posted: Fri Apr 25, 2014 2:21 pm
by xenos
If I had to guess I would say because it is not bootable.
Re: The length of my bootsector
Posted: Fri Apr 25, 2014 2:24 pm
by Isaac
Why isn't it bootable? I assembled it with NASM (if that detail is necessary).
Re: The length of my bootsector
Posted: Fri Apr 25, 2014 2:46 pm
by Minoto
Isaac wrote:I'm now trying to write my own ISO 9660 bootsector and it won't run. QEMU says it's not bootable and a real computer just does nothing. Why not?
You might find
this document helpful.
Re: The length of my bootsector
Posted: Fri Apr 25, 2014 2:53 pm
by SpyderTL
Ouch!
Make sure you have your CD blocks layed out correctly. You have to have an entire CD filesystem in place in order to boot from a CD. It doesn't just load the first block and execute it, like a floppy drive.
The following wiki page goes into detail on the bootable CD format.
El-Torito
If you still have problems, let us know.
Re: The length of my bootsector
Posted: Fri Apr 25, 2014 3:02 pm
by SpyderTL
Just to speed things up, here are some data structures that you are going to need:
Primary Volume Descriptor
Boot Record Descriptor
Supplementary Volume Descriptor
Descriptor Terminator
Boot Descriptor
- Validation Entry
- Default Entry
- Terminator
This is the layout that I'm using, and it seems to work on both real and virtual hardware. Let us know if you have any questions.
Re: The length of my bootsector
Posted: Sat Apr 26, 2014 9:26 pm
by Isaac
I created an image using genisoimage and burned it to a CD_RW. I then tried to boot this CD_RW on real hardware and it didn't work. Is there something I have to add to my bootsector file? Or is it just good enough to create an image in genisoimage? If so, why doesn't my bootsector work?
Re: The length of my bootsector
Posted: Sun Apr 27, 2014 12:28 am
by Combuster
For starters, a CD doesn't have a bootsector, which probably means that what you're trying is not going to work either.
Post your genisoimage command as well as the sizes of all the input files if you want to have a sanity check. You can also leech the correct instructions from the wiki.
Re: The length of my bootsector
Posted: Sun Apr 27, 2014 6:48 pm
by Isaac
My genisoimage command:
Code: Select all
genisoimage -R -b bootsector -no-emul-boot -boot-load-size 2 -boot-info-table -o bootable.iso folder_containing_the_bootsector
I only included one file in my ISO image; my bootsector.
Re: The length of my bootsector
Posted: Tue Apr 29, 2014 10:27 pm
by JohnBurger
Isaac,
As others have said, an ISO doesn't have a bootsector as such. It has a much more complicated environment - but I've already written some NASM code ( [wiki]JohnBurger:Demo/Overview#ISO[/wiki] ) to generate an ISO image at assemble time as part of a bigger Demo.
For your information, when a computer loads a CD at boot time, it actually loads sector #17, not sector #1 (and yes, that's 2,048 byte sectors). But it doesn't just blindly JMP to its first location, so there's no need for the AA55 signature. Instead, that sector is a data table to reference other sectors on the CD.
My code takes advantage of the 32kiB gap at the beginning of the CD to put my code there. It's smaller than 32kiB, so it fits neatly. If yours is larger, you'll need to make some changes...
The trick is that my code sets up the ISO into Floppy emulation mode, so it behaves as if the sectors are 512 bytes in size. The BIOS will read 2,048-byte sectors, but dole them out in 512 byte pieces. And yes, my emulated boot sector has AA55 at location 1FE