Hu Tao
2014-Dec-08 03:20 UTC
[Libguestfs] [PATCH] resize: fix 'No space left on device' problem when copying to an extended partition (RHBZ#1169015)
Because of the size of an extended partition reported by Linux is always 1024 bytes, so it will always fail to copy to an extended partition. This patch fixes this problem by copying to the offset of an extended partition in the destination disk. Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> --- resize/resize.ml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/resize/resize.ml b/resize/resize.ml index 363e2b6..ca5f87d 100644 --- a/resize/resize.ml +++ b/resize/resize.ml @@ -1139,9 +1139,15 @@ read the man page virt-resize(1). * source = "/dev/sda2", because the device name only covers * the first 1K of the partition. Instead, copy the * source bytes from the parent disk (/dev/sda). + * + * You can't write directly to the extended partition, + * because the size of it reported by Linux is always 1024 + * bytes. Instead, write to the offset of the extended + * partition in the destination disk (/dev/sdb). *) let srcoffset = p.p_part.G.part_start in - g#copy_device_to_device ~srcoffset ~size:copysize "/dev/sda" target + let destoffset = p.p_target_start *^ 512L in + g#copy_device_to_device ~srcoffset ~destoffset ~size:copysize "/dev/sda" "/dev/sdb" ) | OpIgnore | OpDelete -> () in -- 1.9.3
Richard W.M. Jones
2014-Dec-08 11:01 UTC
Re: [Libguestfs] [PATCH] resize: fix 'No space left on device' problem when copying to an extended partition (RHBZ#1169015)
On Mon, Dec 08, 2014 at 11:20:54AM +0800, Hu Tao wrote:> Because of the size of an extended partition reported by Linux is always 1024 > bytes, so it will always fail to copy to an extended partition. > > This patch fixes this problem by copying to the offset of an extended > partition in the destination disk. > > Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> > --- > resize/resize.ml | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/resize/resize.ml b/resize/resize.ml > index 363e2b6..ca5f87d 100644 > --- a/resize/resize.ml > +++ b/resize/resize.ml > @@ -1139,9 +1139,15 @@ read the man page virt-resize(1). > * source = "/dev/sda2", because the device name only covers > * the first 1K of the partition. Instead, copy the > * source bytes from the parent disk (/dev/sda). > + * > + * You can't write directly to the extended partition, > + * because the size of it reported by Linux is always 1024 > + * bytes. Instead, write to the offset of the extended > + * partition in the destination disk (/dev/sdb). > *) > let srcoffset = p.p_part.G.part_start in > - g#copy_device_to_device ~srcoffset ~size:copysize "/dev/sda" target > + let destoffset = p.p_target_start *^ 512L in > + g#copy_device_to_device ~srcoffset ~destoffset ~size:copysize "/dev/sda" "/dev/sdb" > ) > | OpIgnore | OpDelete -> () > inSeems reasonable, but I'm still testing it ... Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Seemingly Similar Threads
- [PATCH] lib: Add optional 'append' parameter to copy-(device|file)-to-file APIs.
- Question: resize: non-sparse copying of extended partition
- Re: [PATCH] lib: Add optional 'append' parameter to copy-(device|file)-to-file APIs.
- [PATCH v3 7/7] resize: add support to resize logical partitions
- [PATCH V5 2/4] resize: add support to resize logical partitions