VMware Communities
f1alan
Contributor
Contributor
Jump to solution

How can I compact a vmdk file that is too big?

Hi,

We have a Ubuntu VM running under VMware Workstation on Windows. The problem is that the VM was incorrectly configured with a 512GB partition on a dynamically resizing virtual disk.

This has not been a major problem for us until now because recently we had a problem with a log file that grew and grew, filling up the entire disk and causing the vmdk file to reach the 512GB maximum. We resolved the issue with the log files but the vmdk file has stayed at the maximum size. We can no longer fit it in our backups...

Initially I thought I could shrink the VM like this:

vmware-vdiskmanager.exe -d disk.vmdk

vmware-vdiskmanager.exe -k disk.vmdk

However, it did not make any difference.

Do I need to repartition the guest OS first? Any tips would be greatly appreciated.

Thanks,

Alan

Reply
0 Kudos
1 Solution

Accepted Solutions
wila
Immortal
Immortal
Jump to solution

Hi,

FWIW I keep a running document on this particular topic here:

Shrink guest on hosted platform - VI-Toolkit

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva

View solution in original post

Reply
0 Kudos
11 Replies
kjlee
Contributor
Contributor
Jump to solution

vmware-tools-cmd disk shrink /

as root should shrink /.

This won't work if you have any snapshots.

It would  be nice, if at least ext4fs had same support as ntfs.

Reply
0 Kudos
voidp
Enthusiast
Enthusiast
Jump to solution

The knowledge base has instructions for this: https://kb.vmware.com/s/article/2019649.

Reply
0 Kudos
kjlee
Contributor
Contributor
Jump to solution

I saw that document, too but found it misleading because they are outdated.

Shrinking disks for Windows guests are much easier in recent versions and it doesn't describe what to do with Linux guests.

Reply
0 Kudos
wila
Immortal
Immortal
Jump to solution

Hi,

FWIW I keep a running document on this particular topic here:

Shrink guest on hosted platform - VI-Toolkit

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
Reply
0 Kudos
f1alan
Contributor
Contributor
Jump to solution

Thank you for your advice. I followed the steps and managed to reduce the disk from 500GB to 11GB!

Before we put this into production again, is there a way to reduce the maximum size to avoid this problem happening in future?

Reply
0 Kudos
wila
Immortal
Immortal
Jump to solution

Hi,

Reducing disk size is not supported and if you write to the disk then it can happen again, although normally only disk that is being written to will expand at the host level.

This doesn't mean that you are stuck to using this as the free VMware Converter allows one to migrate to smaller disks.

The only thing I am not sure about is if it supports your file system.

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
Reply
0 Kudos
f1alan
Contributor
Contributor
Jump to solution

Thanks for the suggestion. I did try the converter yesterday but it didn't give the option to change the disk size. Maybe it doesn't support the file system.

I think we may just have to live with what we have. At least we now know how to shrink the disk if it happens again.

Reply
0 Kudos
wila
Immortal
Immortal
Jump to solution

Hi,

Ok.. well it's all about preventing to write data... so I guess that you could always resize the current partition in the disk of the guest in order to prevent it from happening again.

Note that you can't write out zero's anymore there either (although you could simply add another partition into the unused space and mount it when needed).

A bit of a hack, but it should work.

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
Reply
0 Kudos
f1alan
Contributor
Contributor
Jump to solution

Thanks, I'll look into that. I guess we should never have a reason to zero the data after the partition is resized?

Reply
0 Kudos
wila
Immortal
Immortal
Jump to solution

Hi,

In principle not, but if it wasn't all zero'd out before the resize, at least you can still zero it that way.

In the past there have been people here at the forum who had a P2V'd VM -for example a former bootcamp VM on VMware Fusion- where they were not able to reclaim disk space using the normal way. The reason for that was because they had a large unpartitioned space with non zero data in there.

So I'm just giving a tip and highlighting that scenario and how you could still zero out that part of the disk.

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
Reply
0 Kudos
f1alan
Contributor
Contributor
Jump to solution

OK, thanks again for the advice.

Reply
0 Kudos