Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to backup kvm virtual machines and copy machine's images another path or usb disk? How to copy " qemu raw images"?

share|improve this question
    
Do you use libvirt-based solutions like virt-manager or do you call kvm directly? –  jofel Mar 12 '12 at 8:50
    
Do you want to backup a copy while the virtual machine is running or can you shutdown the VM for the backup? –  jofel Mar 12 '12 at 8:52
    
I dont use libvirt or virt-manager and I can shutdown vm for the backup.Thanks. –  psp mid Mar 12 '12 at 9:02
add comment

2 Answers

Copy kvm virtual machines is not complicated: First, you need to shutdown the virtual machine, then you need to find the disk image where the virtual machine is stored and finally copy it to another place (cp /path/to/disk_image /new_path/).

If the virtual machine is stored on its own partition, use dd if=/dev/PARTITION of=/path/to/backup/backup.img bs=1M or use ddrescue /dev/PARTITION /path/to/backup/backup.img.

The virtual machine images could be stored in different formats. Usually, the qcow2-format is used. To get the raw format, you can use qemu-img convert.

share|improve this answer
    
Note: you don't need to shutdown, you can suspend it, do the copy and resume it. That's what proxmox do, for instance. –  Coren Mar 12 '12 at 10:12
    
I made it(shutdown and cp /path/to/disk_image /new_path/) already.But the file sizes are different.Why different? –  psp mid Mar 12 '12 at 12:50
    
How did you check the file sizes? BTW, there are also checksum programs like sha1sum or md5sum. –  jofel Mar 12 '12 at 12:56
    
orginal image : du -h ==>> 15G clone file: du -h ==>> 9,6G.I didn't check md5sum or sha1sum . –  psp mid Mar 12 '12 at 13:06
    
du returns the used space on the file system. For sparse files this is different from the (real) file size. See en.wikipedia.org/wiki/Sparse_file for more information. –  jofel Mar 12 '12 at 13:13
show 1 more comment

cp is enough for most files. If you prefer to use qemu's utilities, you can qemu-img convert with input and output formats both being raw

share|improve this answer
add comment

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.