openstack-manuals/doc/image-guide/ch_converting.xml
Shuquan Huang 8f703276df Add an admonition about converting windows VM from vmdk to qcow2
In "7. Converting between image formats", people should know if
they convert windows VM, they should take care of the virtio driver.
Otherwise, they will get a blue screen when launching the VM without
installing virtio driver. Or you can set the hw_disk_bus image property
to ide which will avoid this issue, but it will have an significant
cost to performance.

Change-Id: I42e8e71b9c92d7a4514973aafdfcf50876b1758b
Closes-Bug: #1481229
2015-09-01 01:59:28 +00:00

83 lines
4.3 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<chapter xmlns="http://docbook.org/ns/docbook"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="5.0"
xml:id="ch_converting">
<title>Converting between image formats</title>
<para>Converting images from one format to another is generally straightforward.</para>
<simplesect>
<title>qemu-img convert: raw, qcow2, QED, VDI, VMDK, VHD</title>
<para>The <command>qemu-img convert</command> command can do conversion between multiple
formats, including qcow2, QED, raw, VDI (VirtualBox), VHD (Hyper-V), and VMDK (VMware).</para>
<table
rules="all">
<caption>qemu-img format strings</caption>
<thead>
<tr>
<th>Image format</th>
<th>Argument to qemu-img</th>
</tr>
</thead>
<tbody>
<tr>
<td>qcow2 (KVM, Xen)</td>
<td><literal>qcow2</literal></td>
</tr>
<tr>
<td>QED (KVM)</td>
<td><literal>qed</literal></td>
</tr>
<tr>
<td>raw</td>
<td><literal>raw</literal></td>
</tr>
<tr>
<td>VDI (VirtualBox)</td>
<td><literal>vdi</literal></td>
</tr>
<tr>
<td>VHD (Hyper-V)</td>
<td><literal>vpc</literal></td>
</tr>
<tr>
<td>VMDK (VMware)</td>
<td><literal>vmdk</literal></td>
</tr>
</tbody>
</table>
<para>This example will convert a raw image file named <filename>centos7.img</filename> to a qcow2 image file.</para>
<para>
<screen><prompt>$</prompt> <userinput>qemu-img convert -f raw -O qcow2 centos7.img centos7.qcow2</userinput></screen>
</para>
<para>Run the following command to convert a VMDK image file to a raw image file.
<screen><prompt>$</prompt> <userinput>qemu-img convert -f vmdk -O raw centos7.vmdk centos7.img</userinput></screen>
</para>
<para>Run the following command to convert a VMDK image file to a qcow2 image file.
<screen><prompt>$</prompt> <userinput>qemu-img convert -f vmdk -O qcow2 centos7.vmdk centos7.qcow2</userinput></screen>
</para>
<para>
<note>
<para>The <literal>-f <replaceable>format</replaceable></literal> flag is optional.
If omitted, <command>qemu-img</command> will try to infer the image format.</para>
<para>When converting an image file with Windows OS, ensure the virtio driver is
installed. Otherwise, you will get a blue screen of death or BSOD when
launching the image due to lack of the virtio driver. Another option is to
set the image properties as below when you update the image in glance to
avoid this issue, but it will reduce performance significantly.</para>
<screen><prompt>$</prompt> <userinput>glance image-update --property hw_disk_bus='ide' image_id</userinput></screen>
</note>
</para>
</simplesect>
<simplesect>
<title>VBoxManage: VDI (VirtualBox) to raw</title>
<para>If you've created a VDI image using VirtualBox, you can convert it to raw format using
the <command>VBoxManage</command> command-line tool that ships with VirtualBox. On Mac
OS X, and Linux, VirtualBox stores images by default in the <filename>~/VirtualBox VMs/</filename>
directory. The following example creates a raw image in the current directory from a
VirtualBox VDI image.</para>
<screen><prompt>$</prompt> <userinput>VBoxManage clonehd ~/VirtualBox\ VMs/fedora21.vdi fedora21.img --format raw</userinput></screen>
</simplesect>
</chapter>