How to create a bootable floppy image using dd command

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.
Post Reply
Mohamed007
Posts: 14
Joined: Fri Jul 08, 2016 8:44 pm

How to create a bootable floppy image using dd command

Post 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,
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

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

Post 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.
Mohamed007
Posts: 14
Joined: Fri Jul 08, 2016 8:44 pm

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

Post 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?
virtualuk
Posts: 2
Joined: Wed Aug 31, 2016 9:43 pm
Libera.chat IRC: UKCoder

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

Post 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
Post Reply