How to install and use qemu-img on Windows and Linux?

[stordis-toc]

Introduction

This article explains how to use qemu-img on Windows and Linux systems for converting virtual disk images between formats like VHDX, VDI, VMDK, and QCOW2.

Installation

Windows (Manual Download)

  1. Download: Go to qemu.weilnetz.de/w64/ and download the latest installer (e.g., qemu-w64-setup-202xxxxx.exe).
  2. Install: Run the downloaded .exe file.
  3. No PATH needed: Simply use the full path to qemu-img.exe in your commands (see examples below).

Linux

Debian/Ubuntu:

sudo apt install qemu-utils

Conversion Commands

General Syntax:

qemu-img convert -p -f <input_format> -O <output_format> <source> <destination>

VHDX to VDI (Hyper-V → VirtualBox):

qemu-img convert -p -O vdi sonic-vs.vhdx sonic-vs.vdi

VDI to VHDX (VirtualBox → Hyper-V):

qemu-img convert -p -O vhdx sonic-vs.vdi sonic-vs.vhdx

VMDK to QCOW2 (VMware → KVM):

qemu-img convert -p -O qcow2 sonic-vs.vmdk sonic-vs.qcow2

QCOW2 to VHDX (KVM → Hyper-V):

qemu-img convert -p -O vhdx sonic-vs.qcow2 sonic-vs.vhdx

Windows Usage (Full Path Examples)

Run these from PowerShell or Command Prompt:

# VHDX to VDI
"C:\Program Files\qemu\qemu-img.exe" convert -p -O vdi "C:\path\to\source.vhdx" "C:\path\to\destination.vdi"

# VMDK to QCOW2
"C:\Program Files\qemu\qemu-img.exe" convert -p -O qcow2 "C:\path\to\source.vmdk" "C:\path\to\destination.qcow2"

Comments 0

Articles in this section