[Libguestfs] Question: resize: non-sparse copying of extended partition

Richard W.M. Jones rjones at redhat.com
Tue Feb 2 10:18:15 UTC 2016


On Tue, Feb 02, 2016 at 12:09:49PM +0300, Maxim Perevedentsev wrote:
> Hello everyone!
> 
> I faced an issue using virt-resize. I have an image with
> extended -> logical -> pv -> lv -> ext4
> (although I think LVM does not matter).
> 
> And image is 65G virtual size and 1G actualSize.
> When I call virt-resize to 60G, it blindly copies the extended
> partition content,
> but does it non-sparse (resize.ml:1231), irrespective to --no-sparse option.
> So the destination image is 60G actual size.
> 
> Is it a bug, or it was made intentionally (why?) ?
> TY for answers!

I think it's a bug.  We should add the ~sparse flag to
g#copy_device_to_device depending on the state of the 'sparse'
(ie. command line) flag.

Does this untested patch fix it?

diff --git a/resize/resize.ml b/resize/resize.ml
index 8ff4793..6ac1019 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -1228,7 +1228,9 @@ read the man page virt-resize(1).
             *)
            let srcoffset = p.p_part.G.part_start in
            let destoffset = p.p_target_start *^ 512L in
-           g#copy_device_to_device ~srcoffset ~destoffset ~size:copysize "/dev/sda" "/dev/sdb"
+           g#copy_device_to_device ~srcoffset ~destoffset ~size:copysize
+                                   ~sparse
+                                   "/dev/sda" "/dev/sdb"
         )
       | OpIgnore | OpDelete -> ()
   in


Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html




More information about the Libguestfs mailing list