5

I'm trying to shrink an 80GB preallocated CentOS VMDK that I've been given from a previous VMware environment, that I've been asked to get running on another host. The billing arrangement for this new running environment allows for the imported dick image to be no more than 50GB in size. Currently, only about 18GB has been used by the guest OS, leaving 62GB of "available disk space" on the VMDK.

Is there a procedure for shrinking a preallocated VMDK? I have of course considered creating a new VM from scratch at the correct size, but there is too much going on on the VM for the option to be feasible.

Any suggestions on shrinking the VMDK or cloning contents from one VMDK to a smaller VMDK would be much appreciated.

Thanks

simonlehmann
  • 340
  • 1
  • 4
  • 14

2 Answers2

7

Have you checked if the disk is sparse or preallocated? If it's sparse, then you can follow the guide in the article already mentioned by John (defrag in Windows and then shrink using VMware Tools). If you succeed you can use for example StarWind V2V converter to basically clone the vmdk to a new ESXi host. You need to connect to the source host, find your vmdk file, connect to a destination host and select the location where to put your vmdk. I used this procedure a couple of times and it worked for a sparse disk.

Strepsils
  • 4,817
  • 9
  • 14
0

Yes. VMware KB 2019649 Defragmenting and shrinking VMware Workstation virtual machine disks. In short, backup and reduce the disks, then use VMware tools via vmware-toolbox.

ESXi, preferred for servers, officially supports reduce only via V2V type migrations with converter. Search and you will find blog posts from people who have edited VMDKs directly, which is riskier.

I have of course considered creating a new VM from scratch at the correct size, but there is too much going on on the VM for the option to be feasible.

Not being able to do a rebuild can be a problem depending on how paranoid your recovery or migration plans are. Bringing along the OS may include cruft. Normally restoring a virtual disk from backup, or V2V migrating it is easy. If you cannot for some reason, a file share with installers and configs allows a clean install option.

John Mahowald
  • 30,009
  • 1
  • 17
  • 32
  • 2
    Thanks for your response. I've installed vCenter Converter as you suggested, and I can set up a job, with the "Powered Off", and "VMware Workstation or other VMware virtual machine" options selected for both source and destination, selecting the VMDK and providing a path to place the resulting VMDK. As far as I can see, this would class as a V2V migration type? I wasn't able to specify a reduced virtual disk size though. On the step where destination VM hardware details are specified, the data copy options available were "Copy all disks and maintain layout", or "Linked clone". Am I missing it? – simonlehmann Feb 24 '19 at 02:33
  • 2
    Also the below answer suggests the availability of virtual disk size reduction functionality in the vCenter Converter migration process: https://serverfault.com/a/76165/302644 – simonlehmann Feb 24 '19 at 02:35