Create an empty floppy disk with FAT format and file system
1
$ mkfs.msdos -C /path/imagefile.img 1440
Boot sector
1 2
$ dd if=ipl.bin of=floppy.img bs=512 count=1 conv=notrunc # conv=notrunc must be included in order to preserve the rest space
The system itself
1 2 3 4 5 6 7 8 9 10 11
# with file system $ sudo mkdir /media/floppy1/ $ sudo mount -o loop f.img /media/floppy1/ $ sudo cp system.sys /media/floopy1/ $ sudo umount /media/floppy1/
# raw disk $ dd if=system.sys of=imagefile.img bs=1 count=[size of system.sys] seek=[offset on disk] conv=notrunc # you can place system.sys code anywhere you like on the disk, except the first sector # so seek should larger than or equals to 512 # remember to jmp to the right address in memory at the end of your boot sector
Start Qemu
1 2 3
$ qemu-system-x86_64 -fda imagefile.img -s -S # '-s' option makes qemu listen on port tcp::1234 # '-S' option makes Qemu stop execution until you give the continue command
Connect to gdb
1 2 3 4 5 6
$ gdb (gdb) target remote localhost:1234 (gdb) b *0x7c00 (gdb) c (gdb) si ...
Other tips
How to view the codes ?
For now, I just view the raw instructions out of gdb, maybe I will load some gdb scripts later example
1 2
$ nasm ipl.s -o ipl.bin -l ipl.lst $ less ipl.lst
GDB memory dump
This is useful when you want to search for some bytes in the whole memory