Bug 1169015 - virt-resize --expand fails on ubuntu-14.04.img image (regression)
Summary: virt-resize --expand fails on ubuntu-14.04.img image (regression)
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: x86_64
OS: Linux
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
Depends On:
Blocks: 1172659 1172660
TreeView+ depends on / blocked
Reported: 2014-11-28 22:47 UTC by Sylvain Pasche
Modified: 2014-12-10 14:13 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1172659 1172660 (view as bug list)
Last Closed: 2014-12-10 14:13:10 UTC

Attachments (Terms of Use)
virt-resize log (68.98 KB, text/plain)
2014-11-28 22:47 UTC, Sylvain Pasche
no flags Details
the patch tries to fix this bug. (1.72 KB, patch)
2014-12-08 03:26 UTC, Hu Tao
no flags Details | Diff

Description Sylvain Pasche 2014-11-28 22:47:06 UTC
Created attachment 962595 [details]
virt-resize log

Description of problem:

virt-resize fails with an "write: No space left on device" error when trying to expand the http://libguestfs.org/download/builder/ubuntu-14.04.xz image.

I encountered this error by running virt-builder with --size=10G on Fedora 21. It used to work on Fedora 20.

Version-Release number of selected component (if applicable):

rpm -q libguestfs-tools-c 

Steps to Reproduce:
1. curl http://libguestfs.org/download/builder/ubuntu-14.04.xz | xz -cd > ubuntu-14.04.img
2. virt-resize -v -x --expand=/dev/sda1 ubuntu-14.04.img 10G.img 2>&1  | tee virt-resize-log.txt

Actual results:

virt-resize: error: libguestfs error: copy_device_to_device: /dev/sdb2: 
write: No space left on device

(full detail in attached log file)

Comment 1 Sylvain Pasche 2014-11-28 22:48:27 UTC
I forgot the "truncate -s10G 10G.img" command just before running virt-resize.

Comment 2 Richard W.M. Jones 2014-11-29 07:26:44 UTC
I suspect https://github.com/libguestfs/libguestfs/commit/fc34e2d16c2d13d6ae7a381ba931e345ab5ae56d
(which I don't think is wrong) which changes the type
we use when creating the extended partition.  Previously
it would create it as "primary", now it is created as

Comment 3 Sylvain Pasche 2014-11-29 13:28:53 UTC
Looks like it is, if I revert that change it succeeds (tried with libguestfs-1.29.11).

Comment 4 Hu Tao 2014-12-08 03:26:21 UTC
Created attachment 965681 [details]
the patch tries to fix this bug.

Comment 5 Hu Tao 2014-12-08 03:29:22 UTC
Please try the attached patch and feedback. Thanks!

The root cause of the problem is that the size of an extended partition reported by Linux is alwas 1024 bytes, so when you are writing to the device (such as /dev/sdb2) corresponding to the extended partition, you can only write 1024 bytes.

Comment 6 Richard W.M. Jones 2014-12-08 14:11:21 UTC
Hu Tao's patch has gone upstream, please try it out:


Comment 7 Sylvain Pasche 2014-12-09 20:33:34 UTC
I tried the patch on top of libguestfs-1.29.13 and the resizing succeeds now with ubuntu-14.04.img.


Comment 8 Richard W.M. Jones 2014-12-10 14:13:10 UTC
Closing / upstream.

This is likely to be a problem on Fedora 21 & RHEL 7.1 too,
so I am going to clone it.

Note You need to log in before you can comment on or make changes to this bug.