Vmkfstools Windows 10
Contents • • • • • • • • • • • • • • • Purpose This article gives the steps to shrink a Vmware VMDK virtual disk file from command-line with the Vmware utility vmkfstools. As far as it's known this is an unsupported method and can defiantly corrupt or break you virtual disk. So, make a backup first and try at your own risk.
It worked great for me after I figured it all out. I only had to restore from my backup clone once or twice until I got the steps worked out. This was performed on ESXi 5.1 and a CentOS 6.3 VM root partition.
Mar 18, 2012. That I wonder why it's not on the windows GUI: mapping local disks to VMs. You can get more info on for this, like “/vmfs/volumes/datastore1/harddisks/“; vmkfstools -z. Chubold my clone zone. Installing vSphere CLI and Running Commands on Linux 10. VSphere CLI and Running Commands on Windows 12. System Management with vmkfstools 53.
The VM had three virtual drives. Each dedicated to the three primary volumes (root,boot,swap). Not using LVM. Meaning a separate virtual drive for all three volumes. Example Configuration • ESXi 5.1.0-838463 Host • CentOS 6.3 x64 Guest • Root partition is 100GB • /dev/sdb1 • 29GB of space is used Example Goal • Reduce root partition to 50GB STEP 1 Remove All Snapshots on Guest Backup • Power off the VM Guest • Create a clone of the root virtual drive • SSH to ESX Host • Browse to VM folder /vmfs/volumes/datastorename/vmfolder vmkfstools -i hostname.vmdk -d thin bak-hostname.vmdk If all the Snapshots are removed general there shouldn't be any files with 00001 in the name. If there is, most likely something like a backup program has gone wrong and you'll need to repair the virtual disk/s first. Shrink Partition • Boot guest off of GParted Live ISO • Select Root drive • Re-size (Shrink) partition to 49GB = 1024 * 49 = 50176 • Apply changes • Power Off the VM Guest Edit VMDK Descriptor If there are snapshots or possibly orphaned snapshots: the VMDK file will appear empty even if you run cat against it.
Obviously that will need to be fixed before attempting this unsupported shrink method. Math Formula [X * (1024 * 1024 * 1024)] / 512 X = Resulting Size in GB Example [50 * (1024 * 1024 * 1024)] / 512 = 104857600 From ESX Host CLI • vi hostname.vmdk RW 209715200 VMFS 'hostname-flat.vmdk' TO RW 104857600 VMFS 'hostname-flat.vmdk' • Save and Quit:wq In this example we're cutting the drive in half. So the easy math is 209715200 / 2 Clone Edited VMDK Make a clone of the VMDK that is set to only Read and Write to a different size. • vmkfstools -i hostname.vmdk -d thin shrunk-hostname.vmdk In this example when cloning it will stop at 50% during the clone because our new VMDK is half the size of the original.
Swap VMDK Files Replace new shrunk VMDK for the original one.