8

i am trying to write a boot loader(hello world sort). i am using Bochs for simulation (platform Linux-Ubuntu). But i am unable to make an bootable iso for my binary file. Though in tutorial VFD(virtual floppy disk) is used but it is for windows platform. Here is my code for bootloader ( just for testing)

;*********************************************
;    Boot1.asm
;        - A Simple Bootloader for testing if cd is booting or not
;
;    Operating Systems Development Tutorial
;*********************************************

[BITS 16]    ;tell the assembler that its a 16 bit code
[ORG 0x7C00]    ;Origin, tell the assembler that where the code will

Start:

    cli                    ; Clear all Interrupts
    hlt                    ; halt the system

times 510 - ($-$$) db 0                ; We have to be 512 bytes. Clear the rest of the bytes with 0

dw 0xAA55                    ; Boot Signature

i tried master ISO on Ubuntu. It is converting the binary file to ISO but not to bootable ISO. Bochs is showing error "cd is not eltorito" which i googled and found to be standard for bootable ISO.What additional things i have to add to it to make it bootable. i have already added boot signature in the end. Can anyone suggest a reliable application to make a bootable ISO on Ubuntu? My work is stuck due to this.... OR i am pretty sure a lot of people must be involved in OS development on Linux platform. How do you people test?

I have made a bootable flash-drive with Unetbootin with the iso of my bootloader program. switched to Virtual-box and twisted a bit to boot from pendrive, but still its showing it to be non-bootable. I think someone said it correctly that u need a lot of patience in OS development.


:phew finally my bootloader program ran...
I used virtual floppy image to boot my program on Virtual box. Here are the steps in case somebody is struggling with it.
1.Create boot.asm which have your bootloader program.
2.Compile with nasm. nasm -f bin boot.asm -o boot.bin.
3.sudo mkfs.msdos -C /home/username/floppy.img 1440
4.sudo chown username ./floppy.img. link text
5.Copy with dd. dd if=./boot.bin of=./floppy.img.
6.Run VirtualBox and select floppy.img as booting device in your new virtual machine.
PS: you can also attach floppy.img to device "loop" and mount it just as a real floppy disk.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Terminal
  • 1,969
  • 5
  • 21
  • 37
  • 2
    Possible duplicate of [Creating a bootable ISO image with custom bootloader](https://stackoverflow.com/questions/34268518/creating-a-bootable-iso-image-with-custom-bootloader) – Peter Cordes Dec 28 '17 at 01:11

3 Answers3

1

Amongst all the storage locations/methods of retrieval, CD-ROM/El-Torito is the oddball (and don't get me started on Mac CDROM filesystem hybrids)

With Floppy, Harddisk/USB or PXE-TFTP, it suffices to write the object code to the first sector, or in case of tftp, just download-and-execute. It can't get any easier with these.

user562374
  • 3,817
  • 1
  • 22
  • 19
  • This is what i also believe now after trying all sort of s/w for making bootable iso and flashdrive for 3 days .A simple dd command is what happens to be a life-saver...:) – Terminal Jan 15 '11 at 08:58
  • 1
    There is no need to use `dd` and its awkward syntax when `cat >` and `dd_rescue` do. dd is just like eltorito.. – user562374 Jan 16 '11 at 02:05
0

a very simple script will do this in linux as below :-

rm -f disk_images/myos.iso
mkisofs -quiet -V 'MYOS' -input-charset iso8859-1 -o disk_images/myos.iso -b myos.flp disk_images/ || exit

The floppy drive is made as below :-

nasm -f bin -o boot.bin boot.asm
dd if=boot.bin of=floppy.img count=1 bs=512 //for the bootloader

and

dd if=boot.bin of=floppy.img skip seek=1 count=1339 //assuming a 1.44Mb floppy

and then you have the file system

mkdosfs (or whatever system you want ) -C floppy.img 1440

If you ned help for windows , let me know :)

Anirudh Ramanathan
  • 46,179
  • 22
  • 132
  • 191
aasthetic
  • 327
  • 4
  • 21
  • how do we do it in windows? Can POWERISO accomplish this? – ASHUTOSH May 12 '13 at 07:58
  • 1
    `dd if=boot.bin of=floppy.img skip seek=1 count=1339` looks very wrong. First `skip` requires a parameter, but none is specified. skip will skip the number of blocks on the input file (boot.bin) but boot.bin is only 512 bytes so that doesn't make sense. The default block size for DD is 512 so count=1339 looks wrong. I can see it being 2879(for 1.44MB floppy).There is a part of me that believes you were looking to skip over the first block in output file (floppy) image and write 0's to fill out a disk image. This seems like a reasonable solution `dd if=/dev/zero of=floppy.img seek=1 count=2879` – Michael Petch Dec 14 '15 at 18:18
  • I'm also confused by `mkdosfs -C floppy.img 1440` . This will fail if the disk image already exists. And it already exists because it was created with the previous _DD_ commands. – Michael Petch Dec 14 '15 at 18:25
  • 1
    @MichaelPetch You also need the to use the `conv=notrunc` option or the second dd will overwrite the first. I'd flip the order of the two commands `dd if=/dev/zero of=floppy.img seek=2879 count=1 && dd if=boot.bin of=floppy.img count=1 conv=notrunc` or if you actually need a FAT file system on it `mkdosfs -C floppy.img 1440 && dd if=boot.bin of=floppy.img count=1 conv=notrunc`. – Ross Ridge Dec 14 '15 at 19:50
  • @RossRidge In my example `dd if=/dev/zero of=floppy.img seek=1 count=2879` conv=notrunc isn't needed because `seek=1` skips over the first block of the output file (which is the boot sector). it then appends out to the full disk size with 0's. I agree with your comments about `mkdosfs`, but my opinion it isn't even required for a bootable ISO so it isn't even worth bothering with. This answer is actually very confusing and imho nonsensical. Even the question references `mkdosfs` but why? – Michael Petch Dec 14 '15 at 20:15
  • @RossRidge . I found this question and answer so confusing that I ended up writing a new answer for the specific question brought up in this new [SO question](http://stackoverflow.com/q/34268518/3857942) . The question is different enough that I didn't consider it a duplicate, and you'll see my answer differs from this answer. The reason this became an issue is because someone (today) tried to use this answer and wondered why it didn't work. I wish there was way to force an answer to be unaccepted ;-) – Michael Petch Dec 14 '15 at 20:19
  • @RossRidge : Of course if your bootloader needed to bootstrap information from the rest of the FAT12 image, then yes, I'd agree you'd need to format it as a DOS disk. Not sure the person asking the original question was doing that. I almost wonder if someone thought it was a requirement to format the floppy image. I just don't know. – Michael Petch Dec 14 '15 at 20:27
  • @MichaelPetch You're right, I didn't realize `seek` also prevents the output file from being truncated when opened like it normally does. – Ross Ridge Dec 14 '15 at 20:45
-1

Try WinISO, it works perfect for me.

Coder32
  • 1
  • 2