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
|