Archive for February, 2012

 

Reclaim Disk Space from Deleted XenServer Snapshots and Clones

According to Citrix KB article, after deleting all snapshots or clones of a Vm, some disk space still remains allocated. In time this may become an issue, so here is a way to recover that disk space.

Note: The VM will need to be shutdown or suspended (actually, running the following command will suspend the VM anyway):

For Xen Server 5.5 update 1 and later:

coalesce-leaf –u <uuid of VM>

For Xen Server 5.6 and later:

xe host-call-plugin host-uuid=<host-UUID> plugin=coalesce-leaf fn=leaf-coalesce args:vm_uuid=<VM-UUID>

A small script (kudos to http://sysadminnotebook.blogspot.com/2011/07/reclaim-disk-space-from-deleted.html) to automate the process if you need:

#!/bin/bash

MASTER=$(xe pool-list params=master | egrep -o “[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}”)

RUNNING_VMS=$(xe vm-list is-control-domain=false power-state=running params=uuid | egrep -o “[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}”)

for VM in $RUNNING_VMS; do

xe host-call-plugin host-uuid=$MASTER plugin=coalesce-leaf fn=leaf-coalesce args:vm_uuid=$VM

done


#!/bin/bash
MASTER=$(xe pool-list params=master | egrep -o “[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}”)
RUNNING_VMS=$(xe vm-list is-control-domain=false power-state=running params=uuid | egrep -o “[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}”)
for VM in $RUNNING_VMS; do
xe host-call-plugin host-uuid=$MASTER plugin=coalesce-leaf fn=leaf-coalesce args:vm_uuid=$VM
done
~
Login