0

I'm learning Operating System programming and I would like to try my programs/codes on a physical machine instead of virtual ones.

I tried the simplest real mode program (show below):

jmp $ ; will loop forever

times 510-($-$$) db 0 ; padding
dw 0xaa55 ; magic boot sector number

this works fine ont the x86 emulator Bochs after I compiled it and created a floppy disk image using the following instructions:

sudo nasm $1 -f bin -o boot.bin
sudo dd status=noxfer conv=notrunc if=boot.bin of=floopy_image.flp

Everything worked fine so I wanted it to go through further testing so I tried it one VMware Player and Oracle VM VirtualBox after adding the following conversion instructions:

sudo mkdir -p iso
sudo cp floopy_image.flp iso/floopy_image.flp
sudo mkdir -p binaries
sudo cp floopy_image.flp binaries/floopy_image.flp
sudo rm -f floopy_image.flp
sudo mkisofs -no-emul-boot -boot-load-size 4 -input-charset cp437 -o binaries/cdrom_image.iso -b floopy_image.flp iso/

I this point I had an ISO image version of the floppy image. The ISO image worked as well on both virtualization software.

Quite happy with myself I though "Now the final test : Running it on a physical machine". So I tried flashing a flash drive with the ISO file with Balena Etcher and I got an error stating:

It looks like this is not a bootable image.

The image does not appear to contain a partition table, and might not be recognized or bootable by your device

I pressed continue to flash de stick and try it anyway... The computer said there was no bootable device and I should connect one and press any key to continue.

Also not that it didn't work with Rufus either, which gave me the error message:

This image is either non-bootable, or it uses a boot or compression method that is not supported by Rufus...

I had to cover my bases.

One think to keep in mind though is that when I mount the ISO image on windows I can access it and see two files: "Boot.cat" (I believe windows XP had such a file in it installation disc) and "Floopy_I.flp"

Paiku Han
  • 581
  • 2
  • 16
  • 38
  • 1
    BIOSes don't usually expect ISO format on flash drives. I believe they're treated like hard disks, not like CD-ROMs, so they should have a master boot record in sector 0. – Nate Eldredge Mar 07 '21 at 17:30
  • @NateEldredge I could be wrong but I have to disagree. When I re-installed Windows 10 just a few days back, I downloaded the ISO file using their tool. I could have burnt it to a CD-ROM (actually DVD-ROM) but I decided to flash a memory stick instead using Rufus. And it (the install) booted from the stick and I was able to install Windows 10 – Paiku Han Mar 07 '21 at 17:34
  • 4
    Nate is right. What you saw was a carefully crafted iso image. The first 32KiB of an ISO9660 image are reserved for *any* use. This is typically exploited to put an MBR with: 1) A legacy bootloader (eg: isohdpfx) that will load the bootloader in the iso (eg: ISOLinux). 2) A protective partition as defined by the GPT specs 3) an (overlapped) EFI partition. The EFI partition (pointed by both the MBR and GPT partitions) will boot the bootloader in the ISO (e.g. again ISOLinux). The ISO9660 filesystem and the UEFI filesystem will typically points to the same files. – Margaret Bloom Mar 07 '21 at 17:43
  • 3
    On top of the El torito spec (addressed by `mkisofs`) this gives the ISO the ability to boot from 3 modes (EFI, CSM, CDROM). That's 3+1 if you consider that the EFI partition can be found either by the MBR partition table or by the GPT partition table. Unfortunately, I don't know the name of a tool that can make such a hybrid ISO. But I never needed it and thus looked it up on Google. – Margaret Bloom Mar 07 '21 at 17:44

0 Answers0