简体   繁体   English

将 VMDK 文件转换为压缩的 RAW 文件

[英]Convert VMDK file to compressed RAW file

Explanation:解释:

I created one virtual machine on my computer with VMWare.我使用 VMWare 在我的计算机上创建了一台虚拟机。 Now I need to move it on a VPS in Frankfurt.现在我需要将它移到法兰克福的 VPS 上。

Using the function provided by VMWare I created a snapshot (VMDK file)使用VMWare提供的功能我创建了一个快照(VMDK文件)

On the hosting website I must upload a RAW format file.在托管网站上,我必须上传RAW格式文件。

To do the conversion I used qemu-img converter .为了进行转换,我使用了qemu-img 转换器 According to the website, I tried to convert the vmdk to raw using this command:根据该网站,我尝试使用以下命令将 vmdk 转换为原始数据:

qemu-img convert -f vmdk -O raw image.vmdk image.img

It works, but I obtained a largest file.它有效,但我获得了最大的文件。

The VMDK image is 3.22GB and the RAW image after the conversion is 56.3GB VMDK镜像为3.22GB ,转换后的RAW镜像为56.3GB

I have created the Virtual Machine with 60GB of disk size, so if I understood correctly:我已经创建了具有60GB磁盘大小的虚拟机,所以如果我理解正确的话:

  1. The VMDK file contains only the files that I created on the virtual machine. VMDK文件仅包含我在虚拟机上创建的文件。
  2. The RAW file have this big disk size because it get the size that I had indicated during the VM creation. RAW文件具有这么大的磁盘大小,因为它获得了我在创建 VM 期间指定的大小。

If this two observation are right the third question make sense.如果这两个观察是正确的,那么第三个问题就有意义了。

Questions:问题:

  • Is possible to reduce the RAW image size (compress it) ?是否可以减小RAW图像大小(压缩它)

  • I have to buy the VPS , but if I can't compress the RAW image, I have to buy it with 64GB of disk space?我要买VPS ,但是如果我不能压缩RAW图像,我必须买64GB的磁盘空间吗?

  • Could be an idea to resize the allocated disk to the Virtual Machine ( eg. 10GB ) and export it again as VMDK and after that convert to RAW ?将分配的磁盘大小调整为虚拟机(例如10GB )并将其再次导出为VMDK ,然后转换为RAW可能是一个想法?

EDIT 01/10/18 :编辑 01/10/18

After a lots of tests I figured out that is not possible to shrink the virtual disk size, the best solution is to create another VM with smaller disk and copy all the data on it (using rsync).经过大量测试后,我发现无法缩小虚拟磁盘大小,最好的解决方案是创建另一个具有较小磁盘的VM并复制其上的所有数据(使用 rsync)。 If for you is important to not lost users, ssh ftp configuration etc.. I don't know how to do that.如果对您来说重要的是不要丢失用户、ssh ftp 配置等。我不知道该怎么做。 I have created again all the configuration.我再次创建了所有配置。

I have tryed to convert in different format, VDI, HDD, RAW and reduce the virtual disk size is not possible on all the format.我尝试以不同的格式进行转换,VDI、HDD、RAW 和减小虚拟磁盘大小在所有格式上都是不可能的。

It might be possible to convert VMDK to VHD if the VMDK is just a simple/single partition/volume.如果 VMDK 只是一个简单/单个分区/卷,则可能可以将 VMDK 转换为 VHD。 If VMDK contains multiple partitions many tools will fail during conversion.如果 VMDK 包含多个分区,则在转换过程中,许多工具将失败。

If it's convertable to VHD then Windows has disk management to shrink disks/partitions.如果它可以转换为 VHD,那么 Windows 有磁盘管理来缩小磁盘/分区。

You could use this to shrink the VHD and then perhaps convert it back to VMDK.您可以使用它来缩小 VHD,然后再将其转换回 VMDK。

I checked there is an option available: "shrink volume".我检查过有一个选项可用:“缩小音量”。

This might just be the thing you are looking for.这可能正是您正在寻找的东西。

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

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