From: Stefan Hajnoczi Subject: Re: [User Question] How to create a backup of an LVM based maschine without wasting space Date: Fri, 12 Oct 2012 10:42:21 +0200 Message-ID: <20121012084221.GC14822@stefanha-thinkpad.redhat.com> References: <5077BE30.5010209@laukamp.me> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Lukas Laukamp Return-path: Received: from mail-bk0-f46.google.com ([209.85.214.46]:44624 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933574Ab2JLIm0 (ORCPT ); Fri, 12 Oct 2012 04:42:26 -0400 Received: by mail-bk0-f46.google.com with SMTP id jk13so1404315bkc.19 for ; Fri, 12 Oct 2012 01:42:25 -0700 (PDT) Content-Disposition: inline In-Reply-To: <5077BE30.5010209@laukamp.me> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, Oct 12, 2012 at 08:52:32AM +0200, Lukas Laukamp wrote: > I have a simple user question. I have a few LVM based KVM guests and > wan't to backup them to files. The simple and nasty way would be to > create a complete output file with dd, which wastes very much space. > So I would like to create a backup of the LVM to a file which only > locates the space which is used on the LVM. Would be create when the > output file would be something like a qcow2 file which could be also > simply startet with KVM. If the VM is not running you can use "qemu-img convert": qemu-img convert -f raw -O qcow2 /dev/vg/vm001 vm001-backup.qcow2 Note that cp(1) tries to make the destination file sparse (see the --sparse option in the man page). So you don't need to use qcow2, you can use cp(1) to copy the LVM volume to a raw file. It will not use disk space for zero regions. If the VM is running you need to use LVM snapshots or stop the VM temporarily so a crash-consistent backup can be taken. Stefan