Page 1 of 1
How do I write a FAT12 floppy disk image file?
Posted: Tue Nov 19, 2013 1:42 pm
by az
Hello!
I'm fairly new to OS development (I started this Friday), and I've run into a problem with making an image file.
I understand how a simple "Hello world" bootloader work, and also made a clear screen function. (Both without using interrupts)
I should mention that I started reading BrokenThorn's tutorials yesterday, and got to
tutorial 6 before having a problem.
I want to write a floppy disk image in the FAT12 file system, so that I can continue to follow BrokenThorn's tutorials.
The problem I'm having isn't really related to actually loading it (since I haven't got that far yet).
I know that the problem with my current approach is that PowerISO is writing the FAT12 bootsector to the image. How do I avoid that?
When I at first only had a bootsector, it was all fine - because it's just those 512 bytes that the BIOS reads.
Now I also have a second bootloader (or mini asm kernel), so that won't work anymore.
I then tried to search this forum and Google on how to do it. (The forum archive here is huge, so it'll be a big help I bet!)
I'm testing if it works with the binaries downloaded from the
tutorial.
When I've got that working, I'm going to start on my own implementation. I don't want to start writing something I can't test.
Thanks in advance!
Re: How do I write a FAT12 floppy disk image file?
Posted: Tue Nov 19, 2013 3:26 pm
by Nable
Use the
wiki, Luke, it has cookies^W articles.
Did you try to start from
http://wiki.osdev.org/Disk_Images ?
Re: How do I write a FAT12 floppy disk image file?
Posted: Tue Nov 19, 2013 4:15 pm
by az
Yes, and I looked at the "dd" command (I should've mentioned that in my original post).
I managed to create a floppy image, but how do I make it possible to add FAT12 headers to the files?
Sorry if the question is stupid, I don't really know exactly how FAT12 exactly works
yet.
I know that FAT12 has the BIOS Parameter Block in the bootsector, and has same signature as a bootsector (which makes it a bootsector I guess)
And I assume every file has a FAT12 header which contains filename and such.
How do I get that header information in the image?
That's the part that confuses me.
Thanks.
Re: How do I write a FAT12 floppy disk image file?
Posted: Wed Nov 20, 2013 12:01 am
by Combuster
how do I make it possible to add FAT12 headers to the files?
Reading that page a bit further shows the whole shebang of tools for various combinations of filesystems and image files.
But I have a nagging suspicion you're trying to go at this without a clue on what's actually needed. If you're going to make a CD, are you only trying to make that floppy image because PowerISO is telling you it needs one? Have you figured out
why it needs one?
Re: How do I write a FAT12 floppy disk image file?
Posted: Wed Nov 20, 2013 12:37 am
by mrstobbe
Here-here to Combuster's overall assessment of your current predicament (ignoring the OS specifics of their analysis).
But... to clarify some simple steps (already pointed out to you)...
Make a floppy image:
Linux:
Code: Select all
$ dd if=/dev/zero bs=512 count=2880 of=whateverfile.img
... creates an emptry 1.44 meg floppy image named whateverfile.img.
... magically turns that image into a FAT12 formatted one.
Moving on...
Windows... I don't know about windows... forget it.
Moving on again...
If you're looking to make a FAT formatted disk yourself (from scratch... with your own blood sweat and tears)... see
http://en.wikipedia.org/wiki/File_Allocation_Table to get an idea of how to setup the first sector, what's expected of the FAT tables (what clusters are), and how the directory structures are laid out. You'll easily be able to format one from scratch from that, and, as a bonus, be able to write a fully functional mini-driver for reading from the FAT filesystem during boot.
Finally... if you need an empty FAT12 formatted 1.44 image... here you go. Attached. Enjoy.
Re: How do I write a FAT12 floppy disk image file?
Posted: Sun Nov 24, 2013 11:52 pm
by az
Just wanted to say that I no longer have problems with making a formatted floppy disk image.
I am using PowerISO to format it, and then I just overwrite first 512 bytes with my bootsector. I don't know what I was so confused about before to be honest.
I guess I will write my own formatter later on. Gave it a try a few days ago, but I ended up failing writing the FAT.
Thanks for the replies though!
Re: How do I write a FAT12 floppy disk image file?
Posted: Mon Nov 25, 2013 12:04 am
by mrstobbe
dib wrote:I guess I will write my own formatter later on. Gave it a try a few days ago, but I ended up failing writing the FAT.
http://staff.washington.edu/dittrich/misc/fatgen103.pdf is an earlier paper on FAT from MS that I find really useful. It was before they started ignoring documenting the specifics of what they were doing so it actually has very straight-forward and useful technical details in it. When you get back into reading/writing to a FAT FS that is.
Re: How do I write a FAT12 floppy disk image file?
Posted: Mon Nov 25, 2013 12:22 am
by az
mrstobbe wrote:dib wrote:I guess I will write my own formatter later on. Gave it a try a few days ago, but I ended up failing writing the FAT.
http://staff.washington.edu/dittrich/misc/fatgen103.pdf is an earlier paper on FAT from MS that I find really useful. It was before they started ignoring documenting the specifics of what they were doing so it actually has very straight-forward and useful technical details in it. When you get back into reading/writing to a FAT FS that is.
Hi, thanks.
Re: How do I write a FAT12 floppy disk image file?
Posted: Sun Dec 01, 2013 8:28 pm
by nerdguy
As a side note you can also use WinImage (Runs natively on Windows and on Linux through Wine), It gives you options like modifying the bootsector, injecting files etc.