I want turn a physical machine running MS Windows 7 into a VirtualBox virtual machine. This is easy, I have done this before, but this time I needed the virtual size/capacity of the disk to be a fixed and smaller size.
It needs to be fixed because I will install PGP disk encryption on it for compliance reasons. This will expand a dynamic disk to it maximum size.
Aside from this special case there are other reasons for wanting disks to be smaller and fixed. Is my experience. If you run for example a Jenkins build server on a dynamically expanding disk you could see the disk expanding quickly to its maximum size while in the guest OS disk space usage is stable and there is lots of free space.
Using Disk2vhd I have created a vhdx file. This file I converted to vdi format.
vboxmanage clonehd --format VDI MSWIN7.VHDX MSWIN7.vdi
Purportedly with vdi you could decrease virtual size/capacity with commands similar to
vboxmanage modifyhd MSWIN7.vdi --resize 160000
I found that this doesn't work. Even if you try variants you will consistently get error messages like:
Progress state: VBOX_E_NOT_SUPPORTED VBoxManage: error: Resize hard disk operation for this format is not implemented yet!
Below is the disk layout of my vdi disk. I added this to a Ubuntu VM to look at it using Gparted and CloneZilla. Capacity is around 300GB. Unallocated 145GB. Used is around 153GB.
I want to shrink capacity to around 160GB. This should be enough to fit /dev/sdb1
and /dev/sdb2
.
BTW, I tried CloneZilla but it also does not seem to like to shrink the capacity to a smaller disk. I tried various settings in CloneZilla but no success.
How can I decrease virtual size/capacity?