I had to shrink down a Windows disk of an ESXi based Virtual Machine from 240 Gibibyte to about 140 gigabyte.
In this case, it was Windows 7 on ESXi 6.5, but the actual versions do not really matter.
The only way to decrease ESXi .vmdk files is by fiddling with disk sector counts in the text based .vmdk files (not the binaries .vmdk files!) of a diskname.vmdk / diskname-flat.vmdk text/binary pair. This is described for instance in these two articles:
Notes:
- This article presumes you already shrunk your NTFS partition (for instance as described in Consolidating NTFS free space).
- If you only have a binary .vmdk file, then you can use
vmkfstools to create a text/binary pair for you, for instance by using these commands:
vmkfstools --clonevirtualdisk Windows7.vmdk Windows7.thick.vmdk
vmkfstools --clonevirtualdisk Windows7.vmdk Windows7.thin.vmdk --diskformat thin
- You cannot workaround 2. as the
--geometry functionality of vmkfstools only displays existing geometry, see
ESXi has .vmdk files that count disk sizes in sectors, but the tooling that ship with Windows to not show partition sizes in sectors, especially not the partition ending sector.
All permutations of tooling like DISKPART, PowerShell, WMIC and terms partition, ending sector, cylinder, head, etc failed me to return built-in tools.
Luckily, “powershell” “partition” “ending sector” found the documentation for [WayBack] Test Disk | File System | Data Management titled “TestDisk Documentation, Release 7.1, Christophe GRENIER” which lead to:
[WayBack] TestDisk Download – CGSecurity
Download TestDisk & PhotoRec. TestDisk is a free and open source data recovery software tool designed to recover lost partition and unerase deleted files. PhotoRec is a file carver data recovery software tool.
It is available for many platforms, including Windows x86 (fully featured) and x64 (limited features):
There was also the much more convoluted PowerForensics which is also more difficult to install:
As a check (because the calculations by hand are too cumbersome to trust on a first trey), I also downloaded the ISO image of gparted:
Let’s get started for real!
Read the rest of this entry »