QEMUからRAWディスクイメージを起動する

QEMUからRAWディスクイメージを起動する

ディスクイメージファイルがありますここ;ページには、QEMUと次のコマンドを使用してこのイメージを起動できることが示されています。

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

これにより、次のメッセージが表示されます。

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.

エミュレータがロードされますが、PilOSがクラッシュします。これは私が何か間違っていることを意味します。

(おそらくPilOSがブロック0に書きたいのですが、それを行うことはできないからです)

raw私が知る限り、コマンドラインパラメータは次のように渡す必要があります。

$ 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

私のブートデバイスがバス0にあるので、これは失敗すると思います。/dev/sdaしたがって、QEMUのマニュアルページによると、次のいずれかが機能しますが、機能しません。

$ 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

bus=9許可する必要がある引数は、-driveファイル名として解釈されるか完全に無視されます。

QEMUでこれらのrawイメージを正しく起動するには?


これはUbuntu 15.10で、以下を実行します。

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

画像に関するデータ:

$ 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

ベストアンサー1

この-driveオプションは以下のようにパラメータを使用します。

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

...「サブ」オプションの間にはスペースではなくカンマを使用する必要があります。

たとえば、Debian インストーラ CD を起動するためにテストしたものは次のとおりです。

qemu-system-x86_64 -drive format=raw,media=cdrom,readonly=on,file=debian-8.2.0-amd64-DVD-1.iso 

おすすめ記事