WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-users

Re: [Xen-users] Clearout (defrag) of sparse file used for Xen VM

To: xen-users@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-users] Clearout (defrag) of sparse file used for Xen VM
From: Javier Guerra <javier@xxxxxxxxxxx>
Date: Mon, 24 Jul 2006 08:55:25 -0500
Delivery-date: Mon, 24 Jul 2006 06:56:31 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <E39E50172D7A6546BCE3E981C985C9870B0C4627@xxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
References: <E39E50172D7A6546BCE3E981C985C9870B0C4627@xxxxxxxxxxxxxxxxxx>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Internet Messaging Program (IMP) 3.0
Quoting William Hargrove <William.Hargrove@xxxxxxxxxxx>:

> I've got a Xen VM sitting inside a sparse file, as shown below, with the
> VM and it's swap file, each at 69gb

> Has anyone got any suggestions on how I could non-destructively reduce
> the size of the file? We are starting to run out of space on the
> partition these VMs sit on.
> 
> I've been looking at various ext3 based tools to try and defragment the
> file, copy it to a new file, dump and restore the file etc, but none of
> those seem to work.

i think you're approaching the problem from the wrong side: that of the 
underlying filesystem.

on the underlying filesystem, a sparse file that has grown is that big because 
it's holding data.  no sane tool would reduce its size, because that would 
mean throwing out data.

OTOH, since those files are holding virtual block devices, some (most?) of 
that data might be currently unused blocks, that's where you could recover 
some storage.

first, the swapfiles: there's nothing there that must be preserved between 
reboots of the VM, apart from a little formatting header.

just do swapoff on the VM, delete the swapfile, create a new one, attach it to 
the VM, do mkswap and swapon.  the new swapfile should be smaller (at least 
for a while)

now, the filesystem itself.  first do a "df -h" on the VM, to make sure you're 
actually using less storage than the current size of the sparse file.  if the 
VM has 40GB used, you won't be able to recover much; but if you're currently 
using just 10GB, it's worth a try.

the easiest way would be to poweroff the VM, then mount the imagefile with a 
loop device; create a new sparse file, mkfs and mount the new file, and copy 
from one to the other.  use cp -a or tar to preserve owner and privileges.  
umount all and restart the VM with the new image.  don't try to suspend and 
resume with the new image, because it won't be a block-identical copy; just 
equal at the filesystem level.

if you want to reduce downtime, you could do the copying from within the VM, 
but at the end you have to restart it with the new image.

good luck!


------
Javier

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users

<Prev in Thread] Current Thread [Next in Thread>