Categories

Category cover

Automation
43 posts

Category cover

Security
20 posts

Category cover

Notes
19 posts

Category cover

Personal Security
15 posts

Category cover

CISO
14 posts

Category cover

Infrastructure
12 posts

Category cover

Learning paths
9 posts

Category cover

OT/ICS
6 posts

Category cover

UNetLab
4 posts

Category cover

Books
3 posts

Category cover

Write-up
3 posts

Category cover

OSInt
2 posts

Category cover

My life
1 posts

Shrinking VMware VMDK virtual hard disks

Andrea Dainese
May 10, 2012
Post cover

In this post we’ll see how to shrink a virtual (VMDK) disk before releasing the OVF/OVA image.

Developing a VM which will be distributed online, require saving space. After deleting cache, log files, and so on, vmdk files won’t become smaller.

Here is how vmdk disks can be shrunk:

  • (obviously) free all space you can;
  • zero (set to zero) free blocks;
  • manually shrink your vmdk disk.

Under Linux free block can be set to zero creating the biggest zeroed file disk that can fit:

dd if=/dev/zero of=zeroedfile
rm -f zeroedfile

This procedure will securely delete all previously deleted files. In other words, all deleted files became irrecoverable.

Under Windows Secure Delete under Microsoft Windows from Microsoft can be used, and it securely deletes all previously deleted files:

C:>sdelete -c C:

Now vmdk disks became larger. They can be shrunk using vmware-vdiskmanager.exe from VMware vSphere 5.0 Virtual Disk Development Kit :

C:>vmware-vdiskmanager.exe -k "c:UsersadaineseVirtual Machinesvmvm.vmdk"

Now vmdk should be smaller.