简体   繁体   English

将 qcow2 转换为 vmdk 并使其兼容 ESXi 6.0

[英]Convert qcow2 to vmdk and make it ESXi 6.0 Compatible

I am currently working on VMWare virtualization;我目前正在研究 VMWare 虚拟化; I am trying to make a converted image from qcow2 to vmdk work with ESXi Server 6.0.我正在尝试使用 ESXi Server 6.0 制作从 qcow2 到 vmdk 的转换图像。

I have myImage.qcow2 with a disk which is thin provisioned for 300GB.我的 myImage.qcow2 带有一个为 300GB 进行精简配置的磁盘。

I used the image converter tool qemu with the following command我使用图像转换器工具 qemu 和以下命令

qemu-img convert -f qcow2 myImage.qcow2 -O vmdk myNewImage.vmdk 

This command gives me a vmdk image which is only VMWare Workstation compatible.此命令为我提供了一个仅与 VMWare Workstation 兼容的 vmdk 映像。 Therefore, in order to make it ESXi compatible I have to use the vmkfstools with the following command.因此,为了使其与 ESXi 兼容,我必须通过以下命令使用 vmkfstools。

vmkfstools -i myImage.vmdk outputName.vmdk -d thin

The vmkfstools command gives me two files, an metadata.vmdk and the actual data.vmdk. vmkfstools 命令给了我两个文件,一个 metadata.vmdk 和实际的 data.vmdk。

As mentioned above my disk is thin provisioned for 300GB and when I apply vmkfstools it expands the disk and gives me a size of 300GB.如上所述,我的磁盘已精简配置为 300GB,当我应用 vmkfstools 时,它会扩展磁盘并提供 300GB 的大小。

Deploying the image through the vSphere Client works without any problem;通过 vSphere Client 部署映像没有任何问题; however, for the purpose of this project I want to use the ovftool and doing so with such a large image is not feasible.然而,为了这个项目的目的,我想使用 ovftool 并且使用如此大的图像这样做是不可行的。

Is there a way for me to make my .vmdk ESXi compatible without vmkfstools expanding my image to 300GB?有没有办法让我的 .vmdk ESXi 兼容而无需 vmkfstools 将我的图像扩展到 300GB?

Or Is there any other method for me to deploy those 300GB using the ovftool while the disk image is on the datastore, so that it doesn't have to be downloaded/uploaded through the deployment process?或者有没有其他方法可以让我在磁盘映像位于数据存储上时使用 ovftool 部署那些 300GB,这样就不必通过部署过程下载/上传它?

I have been stuck on this for weeks and any help will be highly appreciated.我已经坚持了几个星期,任何帮助将不胜感激。

仅供参考:根据变更日志,此支持已在 Qemu 2.1 及更高版本中添加

qemu-img convert -f qcow2 -O vmdk -o adapter_type=lsilogic,subformat=streamOptimized,compat6 SC-1.qcow2 SC-1.vmdk

This worked for me with VMware 6.7这对我适用于 VMware 6.7

The TL;DR is TL; DR 是

qemu-img convert -f qcow2 -O vmdk -o subformat=streamOptimized source_qcow_image_path destination_path_to_vmdk

For example:例如:

qemu-img convert -f qcow2 -O vmdk -o subformat=streamOptimized \
 CentOS-7-x86_64-GenericCloud-1503.qcow2 \
 CentOS-7-x86_64-GenericCloud-1503.vmdk

Update the vmdk version setting embedded in the converted image using this script:使用以下脚本更新嵌入在转换图像中的 vmdk 版本设置:

* This is what actually worked for me * * 这才是真正对我有用的 *

printf '\x03' | dd conv=notrunc of=<vmdk file name> bs=1 seek=$((0x4))

For example:例如:

printf '\x03' | dd conv=notrunc of=CentOS-7-x86_64-GenericCloud-1503.vmdk bs=1 seek=$((0x4))

source: https://kb.vmware.com/s/article/2144687来源: https : //kb.vmware.com/s/article/2144687

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM