This problem has been bothering me for a long time, and I have no leisure to solve it. I have searched many compression methods online, and I feel that they are too troublesome and complicated. Recently, I have solved it by doing Docker on Windows.

Compression VMDK

DiskGenius is a great tool that many of you have used to partition hard disks, merge data, recover data, and so on. Even virtual hard disk files…

First, open the virtual disk VMDK to be compressed (menu: “Disk – > Open Virtual Disk File”). After you open it, you can see the loaded virtual disk in the left window.

Create a virtual disk VMDK file whose capacity is no smaller than that of the source virtual disk

Select (Tools > Clone Disk). In the dialog box that is displayed, select the source VMDK virtual disk to be compressed in Select Source Disk, select the newly created VMDK virtual disk in Select Target Disk, and click Start to wait for compression to complete.

VMDK is mounted to VirtualBox

First back up the source VMDK, and then compress the VMDK to cover the source VMDK, and then start the VM…

It is not unusual to report the following error

UUID {00000000-0000-0000-0000-000000000000} of the medium
'C:\Users\Neil\.docker\machine\machines\default\disk.vmdk' does not match the value
{131b2a66-a477-41dd-b920-1a0a460d3ec8} stored in the media registry
('C:\Users\Neil\.VirtualBox\VirtualBox.xml'). Return code: E_FAIL (0x80004005) Component: MediumWrap Interface: IMedium {4AFe423B-43e0-e9d0-82e8-ceb307940dda}
Copy the code

The UUID in the compressed VMDK file does not match the UUID in the original registry

So good, let’s go to VirtualBox installation directory C: Program Files\Oracle\VirtualBox

Shift + Right build – > select “Open command Window here”

The input

VBoxManage internalcommands sethduuid C:\Users\Neil\.docker\machine\machines\default\disk.vmdk 131b2a66-a477-41dd-b920-1a0a460d3ec8
Copy the code

Return the UUID value to be modified

UUID changed to: 131b2a66-a477-41dd-b920-1a0a460d3ec8
Copy the code

VMDK moves to another disk

An error occurs when disk. VMDK is moved from disk C to another disk and the virtual disk is pointed to the new disk in VirtualBox

Error: Failed to open the virtual hard disk because the UUID already existsCopy the code

Since this UUID already exists in the registry, we use the command to change the VMDK path

VBoxManage internalcommands sethduuid X:\yourDir\disk.vmdk
Copy the code

Then VirtualBox will point to disk. VMDK again

Reference:

www.diskgenius.cn/exp/compres…

www.cnblogs.com/yjf512/p/43…

Source: VM hard disk VMDK compressed thin and mounted to VirtualBox