How to: Use qemu-img command to convert between vmdk, raw, qcow2, vdi, vhd, vhdx formats/disk images (qemu-img create, snapshot, resize etc.) First we need to have qemu installed on the system, for most of Linux systems, we can install “qemu-utils” for Windows we can download QEMU disk image utility from here. WTF, the disk is full?! How did this happen? You only have a couple of virtual machines, and they are no where near that big. So after checking the file sizes on the host, and the disk usage inside the virtual machines, You find that the the the disk file sizes on the host are maxed out, but the disk images are nowhere near full, when viewed from inside the guest. Qemu-img is the command line utility that’s used to convert various file systems used by hypervisors like Xen, KVM, VMware, VirtualBox. Qemu-img is used to format guest images, add additional storage devices and network storage e.t.c. .WINDOWS 10 USERS: While QEMU Manager does work with Windows 10, you will need to change some settings in order for it to work properly. See the new 'Help' page for more information. Here is a list of virtual disk images available for QEMU Manager.
This page discusses things for Unix systems, there is a separate page forMicrosoft Windows systems.
See the discussion about writeback caching.
You can use the following images to give the GNU/Hurd a try.
Debian GNU/Hurd
There is a QEMU image with Debian GNU/Hurd pre-installed availableas http://people.debian.org/~sthibault/hurd-i386/debian-hurd.img.tar.gz.
Usage:
Please also read the README file: http://people.debian.org/~sthibault/hurd-i386/README
If you have troubles extracting the image, you can usethe gz version http://people.debian.org/~sthibault/hurd-i386/debian-hurd.img.gz,the zip version http://people.debian.org/~sthibault/hurd-i386/debian-hurd.img.zip,or even the plain version http://people.debian.org/~sthibault/hurd-i386/debian-hurd.img (3GiB!)
See the discussion about writeback caching.
Just in case you were wondering: the root password is empty.
Unofficial Images
Note that the following images are unofficial ones: they have been prepared byvolunteers and may not have been tested extensively.
- Disk image with a short intro on translators. Just start it with
qemu -m 1G-drive cache=writeback,file=disk_image.img
.It should work without any of the configuration below. If you want to know what you can do with it, please have a look at its wikipage. And when you use it, please tell me your experience with it! - ArneBab
Also you can use QEMU to easily try one of theHurd LiveCDs.
Debian Installer
Instructions for creating a qemu image from the install CDs from debian installer can be found in the README alongside the d-i Hurd images: http://people.debian.org/~sthibault/hurd-i386/installer/cdimage/
Check if your CPU supports kvm:
If you don't have hardware support (slow):
Do not enable kernel-kqemu, as that assumes some particular behavior from the guest kernel, which we are reluctant to artificially add to gnumach.
If QEMU with KVM is not available, Virtualbox reportedly has betterperformance.
If you have hardware support (recommended):
Intel VTx/VTd: Enable Intel kvm in the BIOS
On a HP xw4600 Workstation: F10, Security->System Security; Enable VTx and VTd
Check that the kvm module is loaded:
Add yourself to the kvm group:
AMD SVM (AMD-V): Enable AMD-V in the BIOS if not enabled.
Check that the kvm module is loaded:
More info on kvm at: http://www.linux-kvm.org/page/FAQ
If your machine supports hardware acceleration, you should really use the kvm variant of qemu, as it speeds things quite a lot.
Performance will be yet better if HAP (EPT or NPT) is available:
Note: If you have hardware support, replace the qemu commands below with kvm, e.g. qemu-ing -> kvm-img.
First off you will need to create a disk image using qemu-img
. I have set mine to 4 GiB, although you should be able to get away with less.
Next you will want to start up QEMU and begin the installation process.
Now at his point do the regular install using hd0
as your harddrive. Partition it and install the base system.
In the installer make your choice of install option: Default install (or your choice)
Note that even if you can set the country and locale, your local keyboard is not yet supported.
In case of problems with timezone or locale settings do the following after the installation is completed
Network: Now configured automatically with dhcp
Partitioning method: Guided (or your choice)
Partitioning /dev/hd0
: All files in one partition.
Important: Since partman does not yet mount other partitions than / automatically at reboot, it is crucial that you choose this option for now.
Once you have finished installing the base system (might take some time) the system is rebooted and next boot will be from the hard disk. Now you are able to log in to your newly installed GNU/Hurd system.
Running the installed system
Starting qemu/qemu-kvm:
Note: See below on port forwarding in the networking section.
Note: Using the vmware vga driver is useful for setting up X windows, see Debian GNU/Hurd
If you have problems with grub hanging during boot with the vmware vga driver: Disable the graphic boot
qemu: fatal: Trying to execute code outside RAM or ROM at 0x000000010010001e
This is due to a bug in QEMU, where the x86_64 QEMU binary fails to properlytruncate addresses in 32-bit mode. Waiting for id:'1386334344-24620-1-git-send-email-agraf@suse.de'
to be applied and becomegenerally available, just use the qemu-system-i386
binary instead.See Debian bug #719633
A few words about the qemu console
During the graphical emulation, you can use the following keys:
Mounting Disk Image on Host
You may wish to mount your disk image on your host system to transfer files. To do this you will first need to find the offset of the partition you wish to mount.
Now take the number of sectors for the beginning of the partition and multiply it by the sector size. My partition starts at sector 63 and I have a sector size of 512 therefore my offset is 32256. For a start at 2048 the ofsset is 1048576.
Having QEMU create virtual FAT disk images
Link to the manual.
QEMU has a facility to create FAT file systems on-the-fly:
The Hurd fatfs
translator currently is read-only, butfor testing executables (etc.) that is enough. And it is much easier thanloop-mounting the file systems images. (Also you don't need `root' rights.)
However, note that there is a bug in fatfs: GNU Savannah bug #25961.
Some further notes about networking and home hints aboutsharing files.
Internet Access
If you just want to access the internet from within QEMU, you can setup pfinet for QEMU's user-networking:
If you are on Debian GNU/Hurd, you can even use DHCP.
To get ssh working:
(See also http://www.nongnu.org/qemu/qemu-doc.html#SEC32.)
Outgoing internet connections should just work then.Testing it can be difficult with a minimal installation,but apt-get update
should work after you have filled out/etc/apt/sources.list
.After that you should be able to install other network packages,but note that ping
doesn't work with QEMU's user-networking stack.
If you want to connect from the host system to the Hurd system running in QEMU, you can use port forwarding in QEMU or to setup something more advanced, like bridged networking.
IRC, freenode, #hurd, 2014-02-12
This is fixed in qemu 2.6
Manager Virtual Yahoo
Port Forwarding in QEMU/KVM

(In the following we assume we use kvm!)
Logging in to Hurd from a terminal in your host system
This is the recommended way to work with a Command Line Interface (CLI) since all your keyboard and locale settings are preserved.
a) with ssh (assuming you have installed openssh-server)
Logging in to the running Hurd:
Copying files:
b) with telnet (assuming you have installed a telnet server, like telnetd)
Logging in to the running Hurd:
c) With the tap interface, see below.
Bridged Networking
What is Needed
- Your Linux kernel will need 802.1d Ethernet Bridging support and TUN/TAP device driver support.
- You will need to install bridge-utils.
Setting Up the Host Bridge
You need to setup a bridge on the host first. This assumes eth0
is down. Full development progress. I have modified my hosts network startup scripts to automatically setup a bridge, you may want to do this also.
Qemu Create Image
At this point you will need to setup br0
as you would normally eth0
(dhcpcd br0
for example).
The qemu-ifup Script
This script gets called when QEMU starts and will attach the tun device to the bridge. QEMU will look for this file at /etc/qemu-ifup
and that is where I keep mine.
Setting up the Network in the Hurd
Now it is time to start-up your QEMU Hurd system and get networking going in there.
Important: Remember you may need to use the -M isapc
or -isa
flag if using an older version of the gnumach package.
Once you have logged in as root
run the pfinet
translator with values that apply to your network. Think of your QEMU client as another computer in your network.
That should do it! Do not forget to edit/update /etc/resolv.conf
to get DNS working.
See 'Linux/Multiboot boot specific' section on QEMU manpage.
Get the multiboot modules. Either extract them from the disk image, or,download:

Qemu Image Format
Generally, these files need to correspond to the ones in the disk image, sodon't forget to keep them up to date.
The kernel image needs to be uncompressed (gunzip gnumach.gz
), as otherwiseyou'll get told: qemu: linux kernel too old to load a ram disk.
Note that, contrary to GRUB's configuration file, you don't specify'argv[0]
' here, and it's fortunate that neither ext2fs nor exec need a commaon their command line..
You can also use --append [..]
, which will show up in /proc/cmdline
.
Command line above crashes with old qemu versions, for instance qemu 1.1.2 on Debian Wheezy, fixed by upgrading to wheezy-backports currently qemu 1.7.0, see Debian bug #741873
These are links that users may find helpful.
Debian after install -- good source of information pertaining to yoursystem after installation.
Image for L4 -- a QEMU image for the Hurd/L4 project.
This page documents how to create a hard disk image in QEMU.
The command[edit]
The standard command for creating a basic hard disk image is this.
Total war rome ii gameplay. It will create an output similar to this:
The command is broken down like this:
- qemu-img - This is the name of the program. It is necessary for using the following command.
- create - This tells qemu-img that we are creating a disk image. Other arguments include 'dd', 'info', 'map', 'measure', 'snapshot', 'rebase', and 'resize'. This will be described in more detail later on.
- -f - An argument that specifies which file format we are going to be using.
- qcow2 - The file format we are using, in this case qcow2. qcow2 is the recommended since it is dynamically allocated - e.g. it only allocates space when needed, but at a (pretty much) unnoticeable speed loss. There are many other file formats, which will be listed below.
- example.img - This specifies the name of the image we are going to be using. It can be whatever, and have whatever extension (or none at all), it doesn't matter.
- 100M - This specifies the size of the virtual disk. 100M stands for 100 megabytes. Of course modern operating systems take up much more than that, so it's recommended to make it at least 30 gigabytes or more, which can be done by replacing 100M with 30G. The following letters are excepted:
- K - K stands for Kilobytes. For instance, 100K would be 100 kilobytes. Unrecommended. You can create hard disk images in pure kilobytes if you wanted, e.g. 30000000k for 30 gigabytes.
- M - M stands for Megabytes. For instance, 100M would be 100 megabytes. You can also create hard disk images in pure megabytes if you want, e.g. 30000M for 30 gigabytes.
- G - G stands for Gigabytes. For instance, 100G would be 100 gigabytes.
- T - T stands for Terabytes. For instance, 1T would be 1 terabyte.
- P - P stands for Petabytes. For instance, 1P would be 1 petabyte. Unrecommended unless you happen to have a supercomputer handy.
- E - E stands for Exabytes. For instance, 1E would be 1 exabytes. Unrecommended unless you happen to have a supercomputer handy. Fun fact: The ext4 file system is capable of a maximum of 1.1529215 exabytes.
File formats[edit]
QEMU can recognize and read several different file formats, but this section will list the ones you can create with qemu-img. Chapter 9optimizing measurementsmr.s learning website.
qcow2[edit]
The recommended file format. It is fast, dynamically allocated, and has decent support in QEMU. However it does have a minor speed loss compared to raw, but this is unnoticeable in normal use.
qcow[edit]
This is an older version of the qcow2 file format. The main difference between the qcow2 and qcow file formats is that qcow2 supports multiple snapshots through a newer, flexible model for storing snapshots. It is recommended to use qcow2 instead.
raw[edit]
As the name suggests - it is a 'raw' file format, which means it will allocate all the space to the disk immediately, e.g. if you formatted a file named raw with 2G as the size, it would take up 2 gigabytes of space on the disk. This is the fastest option, and is recommended if you have a lot of disk space to spare.
vdi[edit]
A file format which is also compatible with VirtualBox 1.1. Recommended only if you are going to be switching through VirtualBox and QEMU frequently.
- static - If set, the image will be created with metadata preallocation.
vmdk[edit]



A file format which is compatible with VMWare 3 and 4. Recommended only if you are going to be switching through VMWare and QEMU frequently. It supports the following arguments:
- compat6 - Create a VMDK 6 image, instead of the default VMDK 4.
- hwversion - Specify the vmdk virtual hardware version. If set, the Compat6 flag cannot be enabled.
vpc[edit]
A file format which is compatible with Windows Virtual PC. Recommended only if you are going to be switching through Windows Virtual PC and QEMU frequently.
vhdx[edit]
A Hyper-V compatible image format. Not recommended unless you're going to switch between Hyper-V and QEMU frequently.
parallels[edit]
A Parallels compatible image format. Not recommended unless you're going to switch between Parallels and QEMU frequently.
file[edit]
Not a file with any format - just a plain raw file.
cow[edit]
Ancient, depreciated QEMU file format that is not present in newer versions. Like qcow2 and qcow, it is a dynamically allocated file format. This cannot be used in Win32. Not recommended.
Read only file formats[edit]
- bochs - Bochs image file
- cloop - Linux Compressed Loop image, useful only to reuse directly compressed CD-ROM images present for example in the Knoppix CD-ROMs.
- dmg - Apple disk image
