For the last few days I have been battling disk space issues on the SAN we use for VMWare. A number of the problems were caused because of old snapshots that were not cleaned up, and began taking up all the drive space on the LUN. If a VM takes up all the remaining disk space, that is bad news because it could cause all of the VM’s on that LUN to crash.
Among the many things I did for drive space, one of them involves optimizing free space on virtual disk drives. This is good for VM’s with thin provisioned disks. If you don’t know what that is, basically you give a virtual hard drive to a machine, and tell it the drive is 20 GB for instance. When VMWare writes the vmdk file it doesn’t create a 20GB file. It creates a file big enough for the VM to use, and gets bigger as needed until it hits the 20GB limit. This way you can host more “large disk” servers on less physical space. It can be dangerous though because one of those virtual disks might actually grow to capacity and ruin it for the rest of your VM’s. Another problem with thin provisioning is that when the OS uses the space, and then later deletes files, the vmdk doesn’t automatically shrink with it.
There are a couple of things you can do though. If you open VMWare tools, there is a shrink tab. From there you can shrink the free space of the drive. However if you get the message below, it is bad news:
Shrink disk is disable for this virtual machine. Shrinking is disabled for virtual disks not used in persistent mode and other factors. For more information, see the documentation for your VMWare product.
Well that is no fun at all! It turns out there is a tool that I mentioned once back in episode 18 where I showed you how to wipe a hard drive remotely using email that can help you out in this instance. One of the tools I mentioned was SDELETE by the now Microsoft owned Sysinternals. If you run SDELETE with the –c switch it will zero out your free space, and thus shrink the size of your vmdk! You have to run this within the offending VM.
Know of any other cool tips to optimize LUN space for VMWare? Let us know in the comments!