I have a disk image file from here; that page says I can boot this image with QEMU and the following command:

$ qemu-system-x86_64  -m 4096  -ctrl-grab  -no-reboot  x86-64.img

That gives a message:

WARNING: Image format was not specified for 'x86-64.img' and probing guessed raw.
     Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
     Specify the 'raw' format explicitly to remove the restrictions.

The emulator loads, but PilOS crashes, which means I did something wrong:

(probably because PilOS wants to write to block 0 but can't)

The raw command line argument is, as far as I can tell, meant to be passed like this:

$ qemu-system-x86_64 -drive format=raw file=x86-64.img 
qemu-system-x86_64: -drive format=raw: drive with bus=0, unit=0 (index=0) exists

That fails (I think) because my boot device is on /dev/sda, bus 0, so one of the following should work according to QEMU's man page (but doesn't):

$ qemu-system-x86_64 -drive bus=9 format=raw file=x86-64.img 
qemu-system-x86_64: -drive bus=9: Could not open 'format=raw': No such file or directory
$ qemu-system-x86_64 -drive format=raw file=x86-64.img bus=9
qemu-system-x86_64: -drive format=raw: drive with bus=0, unit=0 (index=0) exists

The bus=9 argument that -drive should accept is either interpreted as a filename, or completely ignored.

How do I properly boot such a raw image in QEMU?


This is Ubuntu 15.10, running:

QEMU emulator version 2.3.0 (Debian 1:2.3+dfsg-5ubuntu9.3), Copyright (c) 2003-2008 Fabrice Bellard

Data about the image:

$ file x86-64.img 
x86-64.img: DOS/MBR boot sector; partition 1 : ID=0x83, active, start-CHS (0x0,1,1), end-CHS (0x82,246,62), startsector 62, 2006072 sectors; partition 2 : ID=0x82, start-CHS (0x83,0,1), end-CHS (0x15,246,62), startsector 2006134, 2006134 sectors

$ fdisk -lu x86-64.img 
Disk x86-64.img: 670 KiB, 686080 bytes, 1340 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device      Boot   Start     End Sectors   Size Id Type
x86-64.img1 *         62 2006133 2006072 979.5M 83 Linux
x86-64.img2      2006134 4012267 2006134 979.6M 82 Linux swap / Solaris
up vote 22 down vote accepted

The -drive option takes parameters that look like this:

qemu-system-x86_64 -drive format=raw,file=x86-64.img 

... you need to use commas between its "sub"-options, not spaces.

For example, here is one I tested to boot a Debian Installer CD:

qemu-system-x86_64 -drive format=raw,media=cdrom,readonly,file=debian-8.2.0-amd64-DVD-1.iso 
  • how do you specify the raw option for floppy drive in the following qemu-system-x86_64 -fda os.flp to get rid of the warning? – enthusiasticgeek May 31 '16 at 15:32
  • 1
    @enthusiasticgeek it's in the man page—search for "Instead of -fda, -fdb, you can use:" gives -drive file=file,index=0,if=floppy ... so you should be able to add format=raw to that. – derobert May 31 '16 at 15:36
  • ok got it. qemu-system-x86_64 -drive format=raw,file=os.flp,index=0,if=floppy worked! Thanks. – enthusiasticgeek May 31 '16 at 15:56
  • 2
    @Mr.Hyde considering it worked for both me and OP, that's odd! What's the full command line? Maybe it'd be best to ask a new question, you can reference this one in your question. – derobert Dec 5 '16 at 10:23
  • 1
    @Mr.Hyde You don't have a -drive argument there, so that seems to be a different question. Suggest you ask your own question. – derobert Dec 6 '16 at 7:32

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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