Professional Documents
Culture Documents
Howto Shrink A Thin Provisioned Virtual Disk (VMDK) - Virten
Howto Shrink A Thin Provisioned Virtual Disk (VMDK) - Virten
RSS Feed
Howto Shrink a Thin Provisioned Virtual Disk (VMDK)
Posted by fgrehl on November 24, 2014 Go to comments Leave a comment (25)
Thin provisioned disks are a great feature to save capacity as you virtual machines filesystem will never
use the full capacity. I do not know a single system where you do not have at least 10GB of free space for
OS disks. I am not considering databases, applications or fileservers which will grow constantly. Having thin Enter your email address to subscribe to this blog and
receive notifications of new posts by email.
provisioned disk is usually no longer a performance problem so it is a valid design choice even
in production.
A common issue with thin disks is that the size will grow when required, but never shrink. When you
require the capacity only once you might want to get it back from the virtual machine. This post describes
how to reclaim unused space from the virtual machine.
Advertise Here
Virtual Machine Preparation (Windows)
Windows does not automatically zero deleted blocks. Microsoft provides a tool that can zero blocks after
while deleting a file or zero out the entire free space. This is required to reclaim space back from the
VMware ESXi SCSI Sense Code Decoder
virtual disk. VMware ESXi Release and Build Number History
Free ESXi 6.7 - How to Download and get License
1. Download SDelete Keys
2. run sdelete.exe -z [Drive] Free ESXi 6.5 - How to Download and get License
Keys
Create a Bootable ESXi Installer USB Flash Drive
Wait a couple of minutes until the process is finished. Please note that you virtual disk file (VMDK) will
grow to the full size during the process.
Linux does not zero deleted blocks too. There are various tools available to create zeroed blocks. The best
known tool is dd which should be available on all systems.
vma:/mnt/data # df -h
vma:/mnt/data # dd bs=1M count=8192 if=/dev/zero of=zero
This website uses cookies to give you the best online experience. By using our website you agree to our use of cookies. Accept
1 of 5 2/19/2020, 2:12 PM
Howto Shrink a Thin Provisioned Virtual Disk (VMDK) | Virten.net https://www.virten.net/2014/11/howto-shrink-a-thin-provisioned-virtual-d...
file (VMDK)©will
Copyright 2020grow to the |full
Virten.net size during| Impressum
www.v13g.de the process.
/ Privacy Policy | Powered by WordPress and zBench ↑ Top
1. Power off the Virtual Machine, or disconnect the virtual Disk you want to shrink
2. Connect to the ESXi Host with SSH
3. Navigate to the Virtual Machine Folder
4. Verify disk usage with du
5. Run vmkfstools -K [disk]
6. Verify disk usage with du
root@esx3:/vmfs/volumes/ds1/vma $ du -h vma_1-flat.vmdk
7.9G vma_1-flat.vmdk
root@esx3:/vmfs/volumes/ds1/vma $ du -h vma_1-flat.vmdk
1.9G vma_1-flat.vmdk
Share:
Share
Related posts:
← Identify Disk Usage of a Thin Provisioned Virtual Disk Reuse VSAN Claimed Disks as VMFS Datastore →
Reply
This website uses cookies to give you the best online experience. By using our website you agree to our use of cookies. Accept
2 of 5 2/19/2020, 2:12 PM
Howto Shrink a Thin Provisioned Virtual Disk (VMDK) | Virten.net https://www.virten.net/2014/11/howto-shrink-a-thin-provisioned-virtual-d...
You can do it completely without downtime with Extrasphere disks (not VM) migration to another
datastore even on free licensed ESXi host.
Reply
T Jardine April 10, 2019 at 12:01 am
Reply
T. Jardine April 10, 2019 at 1:09 am
Once you migrate to another host the provisioned storage reflects the shrunk size (so
migrate to another host and back again). Note: without vMotion you'll need to have the
VM powered off for the duration.
Reply
fgrehl April 18, 2019 at 11:23 am
Provisioned storage is the amount of space the disk can grow to. So it's correct that it
does not decrease when shrinking disks.
Reply
T. Jardine April 18, 2019 at 5:48 pm
Sorry, typo. The actual VM "Storage Usage" size is properly reflected in the vSphere
UI. Provisioned size obviously does not change.
Reply
fgrehl June 25, 2017 at 1:29 pm
"-K" is the short version for "--punchzero". You don't have to use both switches.
Reply
Raimond Barbaro June 25, 2017 at 7:13 pm
Thanks for your reply. How do you know this? It's not in VMware's own
documentation on that page I linked. Can you please provide a source?
Thanks
Raimond
Reply
fgrehl June 25, 2017 at 7:19 pm
[root@esx4:/vmfs/volumes/57604a1d/pixel] vmkfstools -K
--punchzero pixel.vmdk
Failed to open virtual disk '--punchzero': The system
cannot find the file specified (25)
[root@esx4:/vmfs/volumes/57604a1d/pixel] vmkfstools
--punchzero pixel.vmdk
vmfsDisk: 1, rdmDisk: 0, blockSize: 1048576
Hole Punching: 0% done.
[root@esx4:/vmfs/volumes/57604a1d/pixel] vmkfstools -K
pixel.vmdk
vmfsDisk: 1, rdmDisk: 0, blockSize: 1048576
Hole Punching: 0% done.
Ok thanks.
Reply
This website uses cookies to give you the best online experience. By using our website you agree to our use of cookies. Accept
3 of 5 2/19/2020, 2:12 PM
Howto Shrink a Thin Provisioned Virtual Disk (VMDK) | Virten.net https://www.virten.net/2014/11/howto-shrink-a-thin-provisioned-virtual-d...
time.
Reply
Grant September 24, 2017 at 4:24 am
Oh nvm my last post, I was using ls -l to view the files but that shows the full
provisioned size. du -h *.vmdk shows the actual disk usage size which was being
shrunken correctly.
I would like to shrink the Virtual Disks because I need to safe as much space as possible on my
Storage where the VMs are running.
Is it possible to reduce the disk size to a specified size as i dont see any option to reduce to
specific size.
After zeroing:
#> dd if=/dev/zero of=/test.dat bs=4k
#> rm /test.dat
#> poweroff
This website uses cookies to give you the best online experience. By using our website you agree to our use of cookies. Accept
4 of 5 2/19/2020, 2:12 PM
Howto Shrink a Thin Provisioned Virtual Disk (VMDK) | Virten.net https://www.virten.net/2014/11/howto-shrink-a-thin-provisioned-virtual-d...
cheers!
Reply
Markus January 16, 2020 at 12:37 pm
in use are 5.1GB, meaning the "shrink" should result in a 2.9GB lower .vmdk file size
NAME
Website URL
SUBMIT
This site uses Akismet to reduce spam. Learn how your comment data is processed.
This website uses cookies to give you the best online experience. By using our website you agree to our use of cookies. Accept
5 of 5 2/19/2020, 2:12 PM