I'm following this guide to make a simple bootloader. It generates a file disk.img.

$ dd if=/dev/zero of=disk.img bs=1024 count=1440
$ dd if=vbr.bin of=disk.img count=512 conv=notrunc
$ file disk.img
disk.img: DOS/MBR boot sector

Running qemu-system-i386 and qemu-system-x86_64 on disk.img boots fine, displays the desired text.

I want to be able to boot my actual PC into this "operating system". I figured I could simply run:

$ dd if=disk.img of=/dev/sdc1

...and reboot my PC, selecting Boot from USB at the BIOS, but I get this error:

Invalid partition table!

However, running qemu-system-i386 /dev/sdc and qemu-system-x86_64 /dev/sdc works fine.

How do I write disk.img to my USB stick so that it will boot from my actual BIOS?

  • I believe that your error is that you are writing disk.img to /dev/sdc1 instead of to /dev/sdc – fpmurphy Apr 20 '17 at 3:08

For some reason, the steps I took to create disk.img make it so that disk.img can only be properly written to a floppy. However, eliminating the image file entirely (writing directly to the USB) worked (make sure you're using /dev/sdX instead of /dev/sdXY):

$ dd if=/dev/zero of=/dev/sdc bs=1024 count=1440
$ dd if=vbr.bin of=/dev/sdc count=512 conv=notrunc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.