Reputation: 58
I have been following a tutorial online and have built a 512-Byte bootloader saved as boot.bin
.
I also have a second stage bootloader compiled and saved as 2ndstage.bin
.
My bootloader is written such that the second stage doesn't have to be located directly after the first stage in memory, as it searches for it by file name.
How would I, in Linux, combine both bin files into some sort of file (maybe an image) that I can use with QEMU in order to run my bootloader?
Upvotes: 0
Views: 2529
Reputation: 54325
Create a raw disk image file using dd if=/dev/zero of=image.raw bs=1M count=50
That will make a 50 megabyte image file out of zeros.
If you want to operate on a block device instead of a file, you can loopback mount image.raw as a block device (read losetup
man page)
You can partition the file or loopback device using regular fdisk or sfdisk utilities. Then you can either use other dd
options (read the man page for it) or other options to put your bin files into the right places in the disk image.
After that, undo the loopback device if you made one, and start your qemu / qemu-kvm session using the image.raw file as your disk device. If you did your bootloader correctly the qemu bios will start it.
Upvotes: 1