> ## Content Index
> Fetch the complete content index at: https://sgpublic.xyz/llms.txt
> Use this file to discover other available public pages before exploring further.

# OpenWrt: Install qemu-img to create VDI/VMDK images
- URL: https://sgpublic.xyz/p/2024/02/6aac9cb1810a4800015335f8/
- Published: 2024-02-04T05:41:51.000Z
- Updated: 2024-02-04T05:41:51.000Z
- Author: Haven Madray
- Tags: 网络与路由, OpenWrt, #wp-post

之前重装过 NAS 的系统，重装为 Debian 12，并安装了桌面环境，然后尝试运行之前写好的脚本编译 OpenWrt，然后遇到报错：`Install qemu-img to create VDI/VMDK images`：

```
...
echo '(hd0) /tmp/openwrt/build_dir/target-x86_64_musl/linux-x86_64/tmp/openwrt-x86-64-generic-squashfs-combined.vmdk' > /tmp/openwrt/build_dir/target-x86_64_musl/linux-x86_64/tmp/openwrt-x86-64-generic-squashfs-combined.vmdk.grub2/device.map
/tmp/openwrt/staging_dir/host/bin/grub-bios-setup -m "/tmp/openwrt/build_dir/target-x86_64_musl/linux-x86_64/tmp/openwrt-x86-64-generic-squashfs-combined.vmdk.grub2/device.map" -d "/tmp/openwrt/build_dir/target-x86_64_musl/linux-x86_64/tmp/openwrt-x86-64-generic-squashfs-combined.vmdk.grub2" -r "hd0,msdos1" /tmp/openwrt/build_dir/target-x86_64_musl/linux-x86_64/tmp/openwrt-x86-64-generic-squashfs-combined.vmdk
if command -v qemu-img; then qemu-img convert -f raw -O vmdk /tmp/openwrt/build_dir/target-x86_64_musl/linux-x86_64/tmp/openwrt-x86-64-generic-squashfs-combined.vmdk /tmp/openwrt/build_dir/target-x86_64_musl/linux-x86_64/tmp/openwrt-x86-64-generic-squashfs-combined.vmdk.new; mv /tmp/openwrt/build_dir/target-x86_64_musl/linux-x86_64/tmp/openwrt-x86-64-generic-squashfs-combined.vmdk.new /tmp/openwrt/build_dir/target-x86_64_musl/linux-x86_64/tmp/openwrt-x86-64-generic-squashfs-combined.vmdk; else echo "WARNING: Install qemu-img to create VDI/VMDK images" >&2; exit 1; fi
WARNING: Install qemu-img to create VDI/VMDK images
make[5]: *** [Makefile:158: /tmp/openwrt/build_dir/target-x86_64_musl/linux-x86_64/tmp/openwrt-x86-64-generic-squashfs-combined.vmdk] Error 1
make[5]: Leaving directory '/mnt/core/home/work/openwrt/openwrt/target/linux/x86/image'
make[4]: *** [Makefile:24: install] Error 2
make[4]: Leaving directory '/mnt/core/home/work/openwrt/openwrt/target/linux/x86'
make[3]: *** [Makefile:11: install] Error 2
make[3]: Leaving directory '/mnt/core/home/work/openwrt/openwrt/target/linux'
time: target/linux/install#153.06#27.07#139.58
    ERROR: target/linux failed to build.
make[2]: *** [target/Makefile:30: target/linux/install] Error 1
make[2]: Leaving directory '/mnt/core/home/work/openwrt/openwrt'
make[1]: *** [target/Makefile:24: /tmp/openwrt/staging_dir/target-x86_64_musl/stamp/.target_install] Error 2
make[1]: Leaving directory '/mnt/core/home/work/openwrt/openwrt'
make: *** [/mnt/core/home/work/openwrt/openwrt/include/toplevel.mk:232：world] 错误 2
```

解决方案很简单，搜索你所使用的发行版的安装 `qemu-img` 安装方法，例如 Debian 12：

```
sudo apt install qemu-utils
```