With virtual disks, at least these three levels are involved:
- partition or volume (often called drive) size
- virtual disk size
- virtual disk backing store size
When talking about shrinking disks, they usually explain about below steps, assuming there is a 1:1:1 mapping of the above and backing store of the disk is dynamically growing:
- defragment the files on a partition/volume
- zero-fill the non-used space
- shrink the virtual disk assuming it is a dynamically growing one
For various reasons, virtualisation environments can have pre-allocated virtual disks ensuring the space on the backing store is firmly reserved.
One such occasion can be in VMware (often required for instance with vSphere/ESXi/ESX based infrastructure, but can also be used in Workstation/Fusion/Player) or Virtual Box in fixed disk mode (default there is dynamic).
Here are some links that should me help shrink in those situations:
- Shrinking inside Windows 7 and up is easy with Disk Management (but be aware that NTFS cannot shrink below a certain size which is usually half the size your started with; I need to find links that back this up): [WayBack] Easily Shrink a Volume on a Windows 7 Disk
- VirtualBox has a great VBoxManage tool (both on Windows and Linux/MacOSX) with lots of virtual disk conversion options that are somewhat under-documented:
- [Archive.is] virtualbox.org • View topic – Question about –variant options (clonehd)
Note to self: VMware Workstation/Player/Fusion is happy with--variant Standard
but ESX/ESXi/vSphere requires--variant Fixed,ESX
(see [WayBack] Import VirtualBox VMs in VMware ESXi) - VDI might be an easier route than VMDK: [WayBack] How to resize a VirtualBox vmdk file – Stack Overflow and the very similar [WayBack] How to resize a VirtualBox .vmdk file on MacOS – Vuong Tran – Medium
- [Archive.is] virtualbox.org • View topic – Question about –variant options (clonehd)
- For dynamically allocated disks only: [WayBack] Compacting VirtualBox Disk Images – Windows Guests (tips on SDelete and ZeroFree are at[WayBack] How to Shrink a VirtualBox Virtual Machine and Free Up Disk Space)
- VMware has a virtual disk split over 2 files: a text file describing the disk and a binary file with the actual disk content, so if you know you are doing you can modify the description, then migrate to other storage to shrink the binary [WayBack] Shrink a VMware Virtual Machine Disk (VMDK) – virtualman via [WayBack] Best way to shrink a VMDK file (D Drive) of a VM ? |VMware Communities even though [WayBack] Growing, thinning, and shrinking virtual disks for VMware ESX and ESXi (1002019) tells it is not possible.
- For dynamically allocated disks, VMware Workstation 5 and up can do it as well: [WayBack] Shrinking Virtual Disks
- [WayBack] How to Shrink a Hyper-V Virtual Disk (VHD and VHDX)
- Paragon Hard Disk Manager (HDM) can migrate NTFS partitions from one disk to another, so you can create a smaller virtual disk, then migrate to that.
More on conversion:
- [WayBack] How to convert VirtualBox VDI to VMware VMDK disks
- [WayBack] Importing a virtual machine running in an Oracle VirtualBox to VMware Fusion, Workstation, or Player (2053864) (.OVA seems to use the
--variant Streamed
)
–jeroen
PS: a useful tip by Joe C. Hecht on shrinking:
Oh… On shrinking VM Disks, I make a new growable disk, then use a utility to “smart copy” the partions to the new disk (then replace the disk files in the VM). The “smart copy” just copies the file system – IE what is used (I use an old copy of Paragon Hard Drive Manager). It works out a lot better than writing “zeros”. I then make a compressed image of the whole VM using rar5 compression with a 1GB dictionary size. I then have batch files that can unrar the VM’s on a moments notice (from a collection of over 300).