VMware Cloud Community
MinistrBob
Contributor
Contributor

What are some ways to reduce the size of a virtual machine on ESXi without reducing the disk size of the host operating system (not shrink)?

What are some ways to reduce the size of a virtual machine on ESXi without reducing the disk size of the host operating system (not shrink)?

There are several hypervisors ESXi 5.1, 5.5, 6.0. There are several virtual machines (VMs) that have snapshots. All of these VMs have THIN disk type. There is little disk space left on the hypervisors. What are some ways to reduce the size of a VMs without reducing the disk size of the host operating system (not shrink)?

1) The first thing that comes to mind is to delete some snapshots and this helps. But I can’t delete some pictures, because they are needed.

2) I conducted an experiment on moving (move to) a virtual machine from one hypervisor to another. With this transfer, snapshots are also transferred. I moved one VM that had one snapshot and I took measurements (it is possible that I did the wrong measurements, not 100% sure).

BEFORE:

/vmfs/volumes/50c7659e-3221b402-f0fa-0025906c0540/Automation # ls -al

drwxr-xr-x    1 root root          1820 Oct  4 11:59 .

drwxr-xr-t    1 root root          1960 Aug 30 14:06 ..

-rw-------    1 root root     4244701184 Oct  4 11:59 Automation-000001-delta.vmdk

-rw-------    1 root root           323 Aug 30 15:21 Automation-000001.vmdk

-rw-------    1 root root         28332 Aug 30 15:21 Automation-Snapshot1.vmsn

-rw-------    1 root root     32212254720 Aug 30 15:20 Automation-flat.vmdk

-rw-------    1 root root          8684 Oct  4 11:59 Automation.nvram

-rw-------    1 root root           503 Aug 30 14:25 Automation.vmdk

-rw-r--r--    1 root root           464 Aug 30 15:21 Automation.vmsd

-rwxr-xr-x    1 root root          2815 Oct  4 11:59 Automation.vmx

-rw-r--r--    1 root root           265 Aug 30 14:06 Automation.vmxf

-rw-r--r--    1 root root        292954 Aug 30 15:20 vmware-1.log

-rw-r--r--    1 root root        155428 Oct  4 11:59 vmware.log

/vmfs/volumes/50c7659e-3221b402-f0fa-0025906c0540/Automation # du

35607568

AFTER:

/vmfs/volumes/5b5756e6-af674044-1b69-ac1f6b0ded4e/Automation # ls -al

total 7547920

drwxr-xr-x    1 root root          1680 Oct  4 12:31 .

drwxr-xr-t    1 root root          9660 Oct  4 12:26 ..

-rw-------    1 root root     4244701184 Oct  4 12:31 Automation-000001-delta.vmdk

-rw-------    1 root root           323 Oct  4 12:31 Automation-000001.vmdk

-rw-------    1 root root         28332 Oct  4 12:31 Automation-Snapshot1.vmsn

-rw-------    1 root root     32212254720 Oct  4 12:28 Automation-flat.vmdk

-rw-------    1 root root          8684 Oct  4 12:31 Automation.nvram

-rw-------    1 root root           529 Oct  4 12:28 Automation.vmdk

-rw-------    1 root root           464 Oct  4 12:31 Automation.vmsd

-rwxr-xr-x    1 root root          2615 Oct  4 12:31 Automation.vmx

-rw-------    1 root root        292954 Oct  4 12:31 vmware-1.log

-rw-------    1 root root        155274 Oct  4 12:31 vmware.log

/vmfs/volumes/5b5756e6-af674044-1b69-ac1f6b0ded4e/Automation # du

7546896

Judging by «ls», the file sizes did not decrease, but judging by «du», the total size of the virtual machine decreased by 26 GB and the hypervisor before the transfer showed that the STORAGE USAGE was already 34 GB and after that it became about 8 GB. That is, the transfer has reduced the disk space.

But when I moved another virtual machine, about 1TB in size, also with one snapshot. Unfortunately I did not make the same detailed measurements. But judging by the STORAGE USAGE, this virtual machine did not decrease or decreased so slightly that I did not see the difference.

It turns out that the transfer does not always reduce the size occupied on the disk.

Perhaps someone can explain what the catch is.

I also thought of two ways that might possibly help - please tell me if they help in this matter. But so far I have not conducted any experiments, I decided to consult with the community.

3) Export VM to OVA file and than import it back.

4) Backup VM with, eg. ghettoVCB and than restore it back.

What can you advise on this issue? What methods do you use to solve this problem?

Tags (1)
3 Replies
a_p_
Leadership
Leadership

What's the reason for keeping snapshots? Snapshots are not a replacement for backups! As you can see, they rather cause issues (low free disk space in this case).

The important part here is how much free disk space you currently have, to determine if the free disk space is sufficient to delete a snapshot. Note that deleting a snapshot from the Snapshot Manager will not delete any data, but merge the deltas from the snapshot .vmdk file into its parent .vmdk file.

Regarding the "ls -la" command. This will always show the provisioned space (i.e. the size you configured in the VM's settings) for thin provisioned virtual disks. If you want to get the used disk space run e.g. "ls -lisa" which will show additional information, including the used disk space in kB in the second column.

André

hussainbte
Expert
Expert

even export and import OVA wont help neither will backup restore.

shrinking a VM data file s(vmdk) is not a recommended procedure anyway.

so this request of reducing the size and still have the VM working is not possible

If you found my answers useful please consider marking them as Correct OR Helpful Regards, Hussain https://virtualcubes.wordpress.com/
0 Kudos
MinistrBob
Contributor
Contributor

Thanks for the answer and especially for ls.

There are VMs for development and various experiments are carried out there, so sometimes it becomes necessary to return to some previous state. Therefore, I cannot delete snapshots on such VMs.

I'm generally interested in ways to reduce the occupied space. During operation, the OS increases space consumption. But periodically you can clean unnecessary files. Then there is a lot of free space on the host OS disk, but the size of .vmdk files does not decrease. I would like to know some ways to reduce the size of the .vmdk files in this situation.

I have written 4 ways that I believe can help, and I would like to know the opinion of the community if this is so. And maybe there are some other ways unknown to me.

0 Kudos