[Users] re-thin a disk

Richard W.M. Jones rjones at redhat.com
Fri Mar 15 13:23:24 EDT 2013


On Wed, Mar 13, 2013 at 09:23:04PM +0000, Jonathan Horne wrote:
> I have a virtual machine with a 500GB thin-provisioned disk, and on
> it is about 2GB of data.  Due to a pvmove operation I am running,
> the 500GB disk with 2GB of data is growing and growing and is
> currently 180GB in size, and im sure it will go all the way to the
> 500GB before it stops.
>
> When this process is finished, is there a way to re-thin the disk
> back down to the proper size again?  What about the export/import
> process?  Would that export it to the data size, not the block size?

There's not a way to do this in-place currently, although we're
working on it.

If you can accept a copy, then 'qemu-img convert' will automatically
sparsify disks, although it only works if there is no left-over data
in the blocks.

Also requiring a copy, virt-sparsify can fully sparsify a disk even if
it has left-over but unused data blocks.

See also:

  http://libguestfs.org/virt-sparsify.1.html
  http://libguestfs.org/guestfs-faq.1.html#why-doesnt-virt-sparsify-work-on-the-disk-image-in-place-

 - - -

Your question also made me wonder if there was a tool to do an
in-place sparsification of a thin provisioned DM device, but there
doesn't seem to be anything for that.  *If* such a tool did exist,
then you could use it in conjunction with the following guestfish
command:

  http://libguestfs.org/guestfish.1.html#zero-free-space

ie. something like:

  guestfish -a /dev/vg/guest
  ><fs> run
  ><fs> list-filesystems
  # for each filesystem do:
  ><fs> mount /dev/XXX /
  ><fs> zero-free-space /
  ><fs> umount /

followed by running the non-existent thinning tool.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v


More information about the Users mailing list