Page 1 of 1

How to create a bootable floppy image using dd command

Posted: Tue Aug 30, 2016 6:54 am
by Mohamed007
Hi,
I've wrote a kernel and a bootloader on windows 7 32-bit, and it was easy to test them using vfd and bochs
create a floppy disk using vdf the copy my kernel there and burn my bootloader using debug, pretty easy and straightforward

Now, im using Linux. And i wan't to test my OS using QEMU by creating a floppy image that its first sector contains my bootloader and the rest contains the kernel
i used dd to create a bootable floppy and i tested it with QEMU and the bootloader works and prints a message that the kernel not found because i cant put it in the floppy with the bootlaoder

the command i used

Code: Select all

 dd if=boot.bin of=floppy.img seek=0 count=1 conv=notrunc 
So, how to create such a bootalbe image that contains the my bootlaoder on the first sector and the kernel?
Thanks,

Re: How to create a bootable floppy image using dd command

Posted: Tue Aug 30, 2016 6:59 am
by Octocontrabass
There are several ways. The first two that I can think of:

1. mtools

2. Mount floppy.img to a loop device, then format it (with mkdosfs/mkfs.vfat), mount it, and copy files to it just like a real floppy disk.

Re: How to create a bootable floppy image using dd command

Posted: Tue Aug 30, 2016 7:15 am
by Mohamed007
Octocontrabass wrote:There are several ways. The first two that I can think of:

1. mtools

2. Mount floppy.img to a loop device, then format it (with mkdosfs/mkfs.vfat), mount it, and copy files to it just like a real floppy disk.
can you give me more details about how to do what you said?

Re: How to create a bootable floppy image using dd command

Posted: Wed Aug 31, 2016 9:56 pm
by virtualuk
If you just want to create an image file that is the size of a 1.44MB floppy with no file system on it (e.g. doesn't have FAT) you can use

dd bs=512 count=2880 if=/dev/zero of=disk.img

Then you can transfer your bootloader into the first sector with

dd if=bootloader.bin of=disk.img conv=notrunc