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
Best Answer
The
-drive
option takes parameters that look like this:... you need to use commas between its "sub"-options, not spaces.
For example, here is one I tested to boot a Debian Installer CD: