Copying kernel to a floppy without a filesystem?

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.
shindow
Member
Member
Posts: 26
Joined: Thu Feb 25, 2010 7:35 am

Re: Copying kernel to a floppy without a filesystem?

Post by shindow »

This is done by what your topic says code.google.com/p/mytos

First compile the kernle(e.g. boot.bin,kernel.bin),and write a main program to read this 2 file ,write into a new file floppy.img(1.44M). You can control where the 2 bin file locate in the floppy file,and correspoding the boot program should also use this structure to load the kernel.
User avatar
tongko
Member
Member
Posts: 26
Joined: Wed Nov 07, 2012 2:40 am
Location: Petaling Jaya, Malaysia

Re: Copying kernel to a floppy without a filesystem?

Post by tongko »

What I did for my floppy Image was (linux, root/su):

First, create image file with flat 0s:

Code: Select all

dd if=/dev/zero of=floppy.img bs=512 count=2880
bind the loop dev:

Code: Select all

losetup /dev/loop0 floppy.img
You can use losetup /f to look for the first unused loop device

Format loop0 with ext2 fs:

Code: Select all

mkfs -t ext2 /dev/loop0
Mount loop0 so you can write files to it:

Code: Select all

mount -t ext2 /mnt/floppy
Copy anything needed by your boot-load into floppy (image file). Then umount the image. Write a simple C program to read boot.bin and write to first 512 byte of the image, then read kernel.bin (or second stage loader) and write to the second sector (512th-1023th byte).

All done, point the bochs or virtualbox floppy drive to this image file, then start it.

Hope this help.
P.S. I wrote this in office, so, not too sure about the syntax of command, I actually put this all into the C program and I've throw it out of my brain. But I guess you should get the concept. I learn this from one of the other OS dev website, can't remember which...
Post Reply