Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I run several VM's on KVM/ubuntu, which all get started with the -snapshot parameter (the VM's only compute several things which can be destroyed after reboot).

Out of the docs I've read, the changes are not written back to the image, but stored in temp-files and these are deleted after shutdown.

Now, I wonder where on the filesystem these "temp-files" are stored?

share|improve this question

4 Answers 4

up vote 2 down vote accepted

Try use lsof to find snapshot storage:

# ps aux | grep kvm
$PID ?        Sl   5289:40 /usr/bin/kvm ...
# lsof -n -p $PID
COMMAND   PID USER   FD   TYPE   DEVICE        SIZE     NODE NAME

or one command:

# lsof -n -p $(ps ax | grep [k]vm | awk '{print $1}' | head -1)
share|improve this answer

Since I was examing the same and couldn't find them anywhere on the harddrive I would assume they stay in memory? That would also explain, why they aren't persistent.

If you want to write them to disk, use the save/restore commands. Here you can provide a path.

share|improve this answer

The snapshots are stored wherever you configure them to be. on my F14 it's in /var/lib/libvirt/images, but you can play with storage domains in virt-manager or virsh, however you like.

share|improve this answer
    
it is not about snapshots taken by hand, to store the actual state of the vm, its about where the temp-files are stored by kvm when starting with the -snapshot parameter –  bmaeser Feb 23 '11 at 16:25
    
and that is what my answer refers to exactly –  dyasny Feb 23 '11 at 17:25

Here's a little more concise version of the lsof command used above. This variant has several improvements. One being that it will list ALL the KVM VM's.

$ lsof -n -p $(pgrep kvm | tr '\012' ,)

You could then grep the output looking for .img and .qcow2 files if you knew you were using those extensions to name your VM images.

$ sudo lsof -n -p $(pgrep kvm | tr '\012' ,) |grep -E ".img|.qcow2"
qemu-kvm  3836 root   11u   REG              253,0 10737418240 19169281 /var/lib/libvirt/images/vm1.img
qemu-kvm  3895 root   11u   REG              253,0 48318382080 19890183 /kvm/vm2.img
qemu-kvm  3924 root   11u   REG              253,0 10737418240 19890185 /kvm/vm3.img
qemu-kvm 13594 root   11u   REG              253,0 43881005056 69173572 /var/lib/libvirt/images/vm4.qcow2

You could also go about this and query libvirtd to find out what storage pools it has available.

$ sudo virsh pool-list
Name                 State      Autostart 
-----------------------------------------
default              active     yes       

$ sudo virsh vol-list default
Name                 Path                                    
-----------------------------------------
vm1-d-disk0        /var/lib/libvirt/images/vm1-d-disk0   
vm2-d-disk0        /var/lib/libvirt/images/vm2-d-disk0   
vm3.img            /var/lib/libvirt/images/vm3.img         
...

So the default path would look to be /var/lib/libvirt/images for VMs that are using the default pool. That would be the same directory that temporary files related to -snapshot activity would reside as well.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.