VM snapshots are one of the best virtualization features ever. Butâ€¦have you ever had a VMware vSphere or Hyper-V snapshot grow out of control and fill the datastore the VM resides on? You know what happensâ€¦ even the best VM admins out there seem to get burned once when they create a snapshot for some routine maintenance and just forget about it afterwards. All VMs on that LUN crash and go into a suspended state until free space is added to the datastore.
Sometimes this task is harder than it sounds. If your SAN is out of space, or the SAN management tools are out of your control, you could be stuck.
Butâ€¦ follow a simple trick to give yourself that last little bit of wiggle room in the event that a snapshot fills a datastore.
Add a largeÂ text file to the root of the datastore that you can delete if you need headroom! I know it sounds too simpleâ€¦ but itâ€™s simple and effective.
These directions are updated for VMware 6.5 environments, and work all the way back through vSphere 5.5, but the same concept applies to any hypervisor out there today.
If you’re on a SAN that performs some sort of data savings, through either compression and/or deduplication, this trick also consumes next to no space on the SAN.
How do you do this?
Enable the SSH server, and remote into one of the ESXi hosts. This example is from a vSphere 5.5 ESXi server from my home lab.
Change directories into the root of the datastore that you want to create the file in.
Use the Linux command â€˜ddâ€™ to write a 10GB file (or whatever size of your choosing). Basically, weâ€™re creating a file full of zeroes with a 1MB block size and ten thousand blocks. Simple, eh?
dd if=/dev/zero of=snapshotfailsafe.txt count=10000 obs=1M ibs=1M
It will take a few minutes to create the file. You can see the file creation process with another terminal, and can see the activity in the hostsâ€™ disk performance view in the vSphere Client.
Once done, youâ€™ll see it in the terminal and in the datastore view screen.
If you have a VMware or Hyper-V snapshot that has filled the drive, just hit the datastore browser and delete the failsafe file! You just gained time to better manage the snapshot or move data around toÂ accommodateÂ the growth.
I know this seems unnecessary, but every VMware admin seems to get burned with a rogue snapshot once. Occasionally, itâ€™s more than once.
How can I prevent actually needing this?
That part is pretty simple, too. Just set up a vCenter alert to warn you if you have a snapshot that is growing out of control! The directions for how to do this are located in this VMware KB article. (JustÂ rememberÂ to set up the email server so you actually receive the emails!)
This post is reposted from an older post but was updated for vSphere 6.5.