QEMU 警告:“未为 'flash0.img' 指定图像格式并且探测猜测为原始。”

D. *_*. A 11 virtualization qemu

我正在尝试使用 QEMU 模拟 ARM 架构。我的主机操作系统是 ubuntu 16.04,模拟机内的来宾操作系统也是 ubuntu 16.04。以下是我正在关注的教程:

    sudo apt-get install qemu-system-arm qemu-efi

    dd if=/dev/zero of=flash0.img bs=1M count=64
    dd if=/usr/share/qemu-efi/QEMU_EFI.fd of=flash0.img conv=notrunc
    dd if=/dev/zero of=flash1.img bs=1M count=64

    sudo qemu-system-arm -m 1024 -cpu cortex-a57 -M virt -nographic -pflash flash0.img -pflash flash1.img -drive if=none,file=xenial-server-cloudimg-arm64-uefi1.img,id=hd0 -device virtio-blk-device,drive=hd0 -netdev type=tap,id=net0 -device virtio-net-device,netdev=net0,mac=$randmac
Run Code Online (Sandbox Code Playgroud)

这给了我以下错误:

WARNING: Image format was not specified for 'flash0.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.

WARNING: Image format was not specified for 'flash1.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.
Run Code Online (Sandbox Code Playgroud)

这是我第一次在 QEMU 中模拟机器。您的帮助将不胜感激。

先感谢您。

rid*_*dgy 10

这不是错误,只是警告。由于您的虚拟闪存磁盘是原始设备(由dd),qemu-system 无法猜测磁盘格式。因此,如消息所述,写入块 0(可能是 MBR 或文件系统的某个超级块)受到限制。

为了克服这个问题,您可以将磁盘格式指定为format=raw; 定义然后应该读

sudo qemu-system-arm -m 1024 -cpu cortex-a57 -M virt -nographic -drive file=flash0.img,format=raw,if=pflash -drive file=flash1.img,format=raw,if=pflash -drive if=none,file=xenial-server-cloudimg-arm64-uefi1.img,id=hd0 -device virtio-blk-device,drive=hd0 -device virtio-net-device,netdev=net0,mac=$randmac -netdev type=tap,id=net0
Run Code Online (Sandbox Code Playgroud)