bfrueh
Contributor
Contributor

Why is my VM so big?

Jump to solution

Hello

I'm using VMware Workstation 7.1 and have a VM:

- Ubuntu 10.04 server

- tools

- 40 GB HDD, split into 2 GB chunks, expanding (not pre-allocated)

When I enter df -h from the command line in the guest, it shows /dev/sda1 as 38G, 11G used, 25G available, 31% used.

The size of my virtual disks (all 20 files), however, is almost double the size: 20 GB. Why so big? Where is the extra 9 GB coming from? I tries selecting compact in the disk utility, and it ran for about 10 minutes, but the size of the vmdk files remained unchanged.

Any insight is much appreciated.

Ben

0 Kudos
1 Solution

Accepted Solutions
continuum
Immortal
Immortal

you can create the wiperfile manually inside the guest with dd

see http://www.feyrer.de/g4u/#shrinkimg

then in a second step you can use vmware-vdiskmanager to shrink the vmdk

but this only works when you have no snapshots




___________________________________

VMX-parameters- WS FAQ -[ MOAcd|http://sanbarrow.com/moa241.html] - VMDK-Handbook


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

View solution in original post

0 Kudos
11 Replies
michelin_man
Contributor
Contributor

Hi,

I have a similar set-up:

- ubuntu 10.04 desktop

- tools

- 64 GB HDD single file, expanding

My system monitor says 9.6GiB use; the VM is 28GB.

But I don't think this is a problem: I speculate that its probably how VMware persists the virtual disc: Every time a block gets written to for the first time on the virtual hard disc, a corresponding size of data gets persisted on the physical hard disc. But probably not the other way round: That is when the guest OS deallocates a block on the virtual hard disc, the file on the host OS does not get trimmed down.

If this is so, then a VM should gradually eventually "swell" to around the maximum of its logical drive and stay there.

That's my take on it,

Giannis

0 Kudos
bfrueh
Contributor
Contributor

Thanks for the reply - appreciated.

The VM works fine, and I have the disk space. The problem is that I have to zip it and distribute it to many hundreds of people, so slimming it down is critical. And this disk size is the size immediately following a full clone operation from a snapshot. I would assume that there would be no disk sprawl involved with a newly cloned VM.

Ben

0 Kudos
michelin_man
Contributor
Contributor

When a file gets deleted in the VM, the guest OS designates that block as free. VMware Workstation , I speculate, cannot determine if a block that was written-to at least once, and hece persisted to the physical hard-disc, is still is use or not by the guest OS. That info is knows only by the guest OS.

So, I speculate, that VMware could never be able to shrink a VM's footprint, because it can not tell whether or not blocks are in use or not.

0 Kudos
continuum
Immortal
Immortal

sounds like you did not shrink after the clone

the "compact" feature is a mis-nomer - it does not reduce size of the vmdks




___________________________________

VMX-parameters- WS FAQ -[ MOAcd|http://sanbarrow.com/moa241.html] - VMDK-Handbook


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

0 Kudos
bfrueh
Contributor
Contributor

No shrink after the clone. The original VM had a 5 or 6 snapshots. I have always assumed that when Workstation created a clone, it only grabbed what it needed to.

0 Kudos
admin
Immortal
Immortal

When a file gets deleted in the VM, the guest OS designates that block as free. VMware Workstation , I speculate, cannot determine if a block that was written-to at least once, and hece persisted to the physical hard-disc, is still is use or not by the guest OS. That info is knows only by the guest OS.

Correct.

So, I speculate, that VMware could never be able to shrink a VM's footprint, because it can not tell whether or not blocks are in use or not.

There is a trick we can (and do) use to accomplish this. The Tools shrink process creates a file as big as it can filled with just zeros (then deletes it so the guest doesn't get disturbed). We can recognize the pattern of zeros in the vmdk and recover the space, since reading a nonexistent block returns zeros. I don't remember exactly how to trigger Tools shrink in Linux guests, but I think you run vmware-toolbox from the command line and go to the Shrink tab.

Tools shrink may fail to recover space if you're using an encrypted filesystem, which would cause a zero pattern in the guest to not correspond to a zero pattern on the host. We also cannot currently shrink if a virtual machine has snapshots.

bfrueh
Contributor
Contributor

Thanks for the reply. Much appreciated.

I was able to launch vmware-toolbox on my guest, but no partitions were displayed on the shrink tab. It appears from this thread that ext4 file systems are not supported:

http://communities.vmware.com/message/1535481

The though of rebuilding my VM in Ubuntu 8.04 / ext3 is not exciting. Any other suggestions? I'll start the stages of loss. Anger...denial...

0 Kudos
continuum
Immortal
Immortal

you can create the wiperfile manually inside the guest with dd

see http://www.feyrer.de/g4u/#shrinkimg

then in a second step you can use vmware-vdiskmanager to shrink the vmdk

but this only works when you have no snapshots




___________________________________

VMX-parameters- WS FAQ -[ MOAcd|http://sanbarrow.com/moa241.html] - VMDK-Handbook


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

0 Kudos
Borja_Mari
Virtuoso
Virtuoso

Hi,

i would like to add the the same "issue" happens when making vm's backup.

The workaround it's the same Smiley Happy


Regards/Saludos,
Pablo

Please consider awarding

any helpful or corrrect answer. Thanks!! -

Por favor considera premiar

cualquier respuesta útil o correcta. ¡¡Muchas gracias!!

Virtually noob blog

------------------------------------------------------------------------------------------------- PLEASE CONSIDER AWARDING any HELPFUL or CORRECT reply. Thanks!! Por favor CONSIDERA PREMIAR cualquier respuesta ÚTIL o CORRECTA . ¡¡Muchas gracias!! VCP3, VCP4, VCP5-DCV (VCP550), vExpert 2010, 2014 BLOG: http://communities.vmware.com/blogs/VirtuallyAnITNoob
0 Kudos
bfrueh
Contributor
Contributor

Thank you continuum - this saved me. To summarize:

If you have a Linux VM with growable virtual disks using a journaling file system (ext4, xfs, etc), your disk will not appear on the shrink tab of vmware-toolbox or be listed when using vmware-toolbox-cmd. To shrink, enter the following commands from within the guest to manually wipe the guest disk:

dd if=/dev/zero of=/0bits bs=20971520 # bs=20m

rm /0bits

Then shutdown the VM and use vmware-vdiskmanager to shrink:

vmware-vdiskmanager -k nameOfYourVirtualDisk.vmdk

0 Kudos
osde_info
Enthusiast
Enthusiast
0 Kudos