From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephane CHAZELAS Subject: Re: Convert one .img disk created with sparse=true to no sparse Date: Thu, 20 Oct 2011 14:56:40 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE To: kvm@vger.kernel.org Return-path: Received: from lo.gmane.org ([80.91.229.12]:35203 "EHLO lo.gmane.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756356Ab1JTPpO (ORCPT ); Thu, 20 Oct 2011 11:45:14 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RGunu-0005nL-4s for kvm@vger.kernel.org; Thu, 20 Oct 2011 17:45:10 +0200 Received: from 188-223-3-27.zone14.bethere.co.uk ([188.223.3.27]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 20 Oct 2011 17:45:10 +0200 Received: from stephane_chazelas by 188-223-3-27.zone14.bethere.co.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 20 Oct 2011 17:45:10 +0200 Sender: kvm-owner@vger.kernel.org List-ID: 2011-10-20, 13:21(+02), Gonzalo Marcote Pe=C3=B1a: > I have one guest that I created with virt-install comand option 'spar= se=3Dtrue'. > As i want to use now this guest for I/O tasks (DDBB) and i want to > improve performance, I want to convert the disk.img from sparse to no > sparse (obviusly without format it). > How can I do this task without loosinf the disk image data?. > Thank you. [...] You'll have to make a separate copy anyway as your aim is to have all the data contiguous on disk. If it's a raw image. cat < old.img > new.img cp --sparse=3Dnever old.img new.img Or you can use qemu-img convert. Or you could use a LVM volume instead of file. This way, you have more control on which sectors are allocated and can force them to be contiguous. On extent based FS (ext4, btrfs...), there might be a way to guarantee as few extents as possible, but I don't know it. --=20 Stephane