VMware ESX - Getting rid of disk-space hungry snapshots 

Tags: VMware

Getting rid of disk-space hungry snapshots on VMware Server isn't  really a push-button task and requires a bit of creativity. If you make a snapshot on a production vm in your virtual infrastructure, don't keep it much longer than a day or two at the most. The snapshot will grow automatically to a max of the original vmdk.

http://virtrix.blogspot.com/2006/11/vmware-how-big-can-vm-snapshots-grow.html

Remove a snapshot is easy, right? Sure.... till the task times out.

http://blog.frode.org/?tag=remove-snapshot

The vmdk snapshot file for the VM had grown to several GB’s. Think twice before you press the “delete all” button. When you hit that button, all the snapshots will merge into the original “flat.vmdk”-file  and afterwards all snapshots are deleted.

http://www.yellow-bricks.com/2008/01/07/delete-all-snapshots/

This action takes a while and there are a lot of strange things/problems in VirtualCenter e.g. “VirtualCenter shows no snapshot but it still exist in the ESX under the VirtualMachine directory on the datastore”, VM’s get stuck,… So before you make and remove snapshots, try to understand how a snapshot works and which files are involved:

http://www.virtualizationtrainings.com/vmware-advanced-study/all-about-snapshots-in-vmware-vi3
<machine name>-SnapshotX.vmsn (Where X is the number of the snapshot taken) This file stores the state of the virtual machine when the snapshot was taken.

<machine name>-SnapshotX.vmem (Where X is the number of the snapshot taken) This file stores the state of the virtual machine memory when the snapshot was taken.

<machine name>-n.vmdk (where n is the number of the disk image)

If you want to remove snapshots, never use the snapshotmanager if you want to relax that day!

http://professionalvmware.com/2009/01/19/removing-vmware-snapshots-with-a-bat-powershell-cli-rcli/

Snapshots get stuck, like glue, to a running VM, and despite your best effort to delete them, they won’t go away. Like in-laws, they stick around, a bit longer than is pleasant. If a snapshot has not been removed cleanly on the first try, you may want to create a new snapshot first (just to make sure the system knows there IS a snapshot present) before using the methods below.

Here are a few ways of getting rid of the ones that don’t want to go away:

From the Service Console (ESX)

[root@esx esx:storage1]# vmware-cmd ./VMname/VMname.vmx removesnapshots removesnapshots() = 1

From PowerShell

PS C:\> get-vm VMname* | get-snapshot | Remove-Snapshot -Confirm:$false

Using the rCLI

Install RCLI on a virtualcenter machine

Probably you get an error about a library: http://theether.net/kb/100062

add “C:\Program Files\VMware\VMware VI Remote CLI\Perl\bin” to path environments

C:\Program Files\VMware\VMware VI Remote CLI\bin>vmware-cmd.pl -H esx -U root –P  password /vmfs/volumes/esx:storage1/VMname/VMname.vmx removesnapshots removesnapshot () = 1

Using the Perl Toolkit

./snapshotmanager.pl –server your.vc.host –operation removeall –vmname some.bad.vm

I used the Perl Toolkit (it’s installed with RCLI):

C:\Program Files\VMware\VMware VI Remote CLI\Perl\apps\vm>snapshotmanager.pl -server EsxServer.arfyes.com -operation removeall -vmname VMname

Enter username: root
Enter password:

Warning: depending on the size of the snapshot, it may take a LONG while for them to go away! You can get an idea of how long it’s going to take by looking at how large the snapshots are with ls -lh and note the size of your largest snapshots.

 
Posted by Lieven Meys on 9-Mar-09
0 Comments  |  Trackback Url | Bookmark this post with:        
 
ab

Comments

Your name  *
Email  *
Your URL 
Comment  *

Please enter the text from the image


Contact us - Raas Van Gaverestraat 83, 9000 Gent, Belgium - Tel. +32 (9) 330.15.00 - Privacy Statement - Sitemap - Sign In Developed with Microsoft Office SharePoint Server 2007