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 15:57:44 +0000 (UTC) Message-ID: References: To: kvm@vger.kernel.org Return-path: Received: from lo.gmane.org ([80.91.229.12]:37502 "EHLO lo.gmane.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754835Ab1JTP57 (ORCPT ); Thu, 20 Oct 2011 11:57:59 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RGv0H-0003XG-Ug for kvm@vger.kernel.org; Thu, 20 Oct 2011 17:57:57 +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:57:57 +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:57:57 +0200 Sender: kvm-owner@vger.kernel.org List-ID: 2011-10-20, 14:56(+00), Stephane CHAZELAS: [...] > On extent based FS (ext4, btrfs...), there might be a way to > guarantee as few extents as possible, but I don't know it. Actually, with both ext4 and btrfs, it is possible to defrag a file in place. So you could un-sparse the file first: make sure it is not being used otherwise and: cat < old.img 1<> old.img or pv < old.img 1<> old.img to get a progress bar. and defrag it: e4defrag -v old.img btrfs filesystem defragment -v old.img (not tested). -- Stephane