Bug 1266658 - virt-builder ubuntu-14.04 --size fails: Extended partition already exists.
virt-builder ubuntu-14.04 --size fails: Extended partition already exists.
Status: CLOSED ERRATA
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
unspecified
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Richard W.M. Jones
: Reopened
: 1282732 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-09-26 04:39 EDT by Richard W.M. Jones
Modified: 2015-12-16 04:53 EST (History)
4 users (show)

See Also:
Fixed In Version: libguestfs-1.30.5-1.fc22 libguestfs-1.30.5-2.fc23 libguestfs-1.30.5-2.fc22
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-12-05 20:22:04 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Richard W.M. Jones 2015-09-26 04:39:39 EDT
Description of problem:

$ virt-builder ubuntu-14.04 --size 20G
[   0.9] Downloading: http://libguestfs.org/download/builder/ubuntu-14.04.xz
[   2.9] Planning how to build this image
[   2.9] Uncompressing
[  12.8] Resizing (using virt-resize) to expand the disk to 20.0G
virt-resize: error: libguestfs error: part_set_mbr_id: sfdisk --part-type: 
Extended partition already exists.
sfdisk: /dev/sdb: partition 2: failed to set partition type

It works without the --size parameter.

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

libguestfs-1.31.7-1.fc24.x86_64
Comment 1 Ting-Wei Lan 2015-10-25 02:39:54 EDT
This also happens when building a debian image.

$ virt-builder debian-8 --size 16G 
[   1.4] Downloading: http://libguestfs.org/download/builder/debian-8.xz
[   2.1] Planning how to build this image
[   2.1] Uncompressing
[  14.1] Resizing (using virt-resize) to expand the disk to 16.0G
virt-resize: error: libguestfs error: part_set_mbr_id: sfdisk --part-type: 
Extended partition already exists.
sfdisk: /dev/sdb: partition 2: failed to set partition type


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

libguestfs-1.30.0-1.fc22.x86_64
Comment 2 Richard W.M. Jones 2015-10-27 04:50:24 EDT
(In reply to Ting-Wei Lan from comment #1)
> This also happens when building a debian image.
> 
> $ virt-builder debian-8 --size 16G 
> [   1.4] Downloading: http://libguestfs.org/download/builder/debian-8.xz
> [   2.1] Planning how to build this image
> [   2.1] Uncompressing
> [  14.1] Resizing (using virt-resize) to expand the disk to 16.0G
> virt-resize: error: libguestfs error: part_set_mbr_id: sfdisk --part-type: 
> Extended partition already exists.
> sfdisk: /dev/sdb: partition 2: failed to set partition type
> 
> 
> Version-Release number of selected component (if applicable):
> 
> libguestfs-1.30.0-1.fc22.x86_64

Try a more up to date version such as 1.30.4 available in updates-testing:

https://bodhi.fedoraproject.org/updates/?packages=libguestfs
Comment 3 Ting-Wei Lan 2015-10-29 23:27:47 EDT
I tried libguestfs-1.30.4-1.fc22.x86_64, but it still failed with the same error.

sfdisk --part-type /dev/sdb 2 5
Extended partition already exists.
sfdisk: /dev/sdb: partition 2: failed to set partition type
[   11.282273]  sdb: sdb1 sdb2 < sdb5 >
guestfsd: error: sfdisk --part-type: Extended partition already exists.
sfdisk: /dev/sdb: partition 2: failed to set partition type
guestfsd: main_loop: proc 236 (part_set_mbr_id) took 0.01 seconds
virt-resize: error: libguestfs error: part_set_mbr_id: sfdisk --part-type: 
Extended partition already exists.
sfdisk: /dev/sdb: partition 2: failed to set partition type

If reporting bugs, run virt-resize with debugging enabled and include the 
complete output:

  virt-resize -v -x [...]
libguestfs: closing guestfs handle 0x2554ac0 (state 2)
Comment 4 Richard W.M. Jones 2015-10-30 05:56:37 EDT
It turns out I was thinking of another bug.  This one is not even
fixed upstream.

I have now fixed this *upstream* by reverting a bunch of changes
we did last year when we hoped to add support for extended
partitions to virt-resize (which we are no longer going to do).

The commits are:

https://github.com/libguestfs/libguestfs/commit/b1a7903fd12f86f64aac8e3829757a2bf949ec6c
https://github.com/libguestfs/libguestfs/commit/8ad069c402a451fb40a9c03fe9045f7ef9cc1e69
https://github.com/libguestfs/libguestfs/commit/3258695162f4fa1bbf8499bf604d8d5e51460d93
https://github.com/libguestfs/libguestfs/commit/db5ebecd8a0a762c73de22b67b63f23572a585e2

These will appear in 1.30.5 / 1.31.21.
Comment 5 Richard W.M. Jones 2015-11-17 04:55:34 EST
*** Bug 1282732 has been marked as a duplicate of this bug. ***
Comment 6 Marius Vollmer 2015-11-17 05:23:45 EST
Another avenue for fixing this would be to change the debian and ubuntu templates to not use extended partitions, no?
Comment 7 Richard W.M. Jones 2015-11-17 05:42:20 EST
Ubuntu's installer at least seems to prefer extended partitions.

In any case this is just a bug in virt-builder and will be fixed in
1.30.5, or by backporting the 4 commits mentioned in the
other BZ to 1.30.4.
Comment 8 Fedora Update System 2015-11-20 03:31:01 EST
libguestfs-1.30.5-1.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2015-da3879aa60
Comment 9 Fedora Update System 2015-11-20 03:31:12 EST
libguestfs-1.30.5-1.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2015-d73e2fad1e
Comment 10 Fedora Update System 2015-11-21 12:52:45 EST
libguestfs-1.30.5-1.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
$ su -c 'dnf --enablerepo=updates-testing update libguestfs'
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-d73e2fad1e
Comment 11 Fedora Update System 2015-11-22 09:26:36 EST
libguestfs-1.30.5-1.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
$ su -c 'dnf --enablerepo=updates-testing update libguestfs'
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-da3879aa60
Comment 12 Marius Vollmer 2015-11-26 09:57:45 EST
The resizing of the debian-8 image now works, but the swap partition seems to be removed in the process.  This leads to a 90sec delay during boot and no swap.

Regarding virt-resize, I think it is OK if it just gives up (with a clear error message) when there are setups it can't handle, such as extended partitions.

Regarding virt-builder, I strongly think that it should provide templates that can be resized.  This means avoiding partition setups that virt-resize can't handle.

I am quite surprised that Debian defaults to putting swap into a extended partition.  How odd.  I'll ask around a bit.
Comment 13 Marius Vollmer 2015-11-26 10:19:36 EST
> I am quite surprised that Debian defaults to putting swap into a extended
> partition.  How odd.  I'll ask around a bit.

Maybe they do this because you can only have four primary partitions.

Would it be acceptable to make new debian-8 images that don't use extended partitions?
Comment 14 Richard W.M. Jones 2015-11-26 11:28:16 EST
I opened another bug about the data loss issue:
https://bugzilla.redhat.com/show_bug.cgi?id=1285847
Comment 15 Fedora Update System 2015-11-28 02:15:45 EST
libguestfs-1.30.5-2.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2015-943e9fb63b
Comment 16 Fedora Update System 2015-11-28 02:15:49 EST
libguestfs-1.30.5-2.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2015-1bf4cbf156
Comment 17 Fedora Update System 2015-11-28 19:54:17 EST
libguestfs-1.30.5-2.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
$ su -c 'dnf --enablerepo=updates-testing update libguestfs'
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-1bf4cbf156
Comment 18 Fedora Update System 2015-11-28 21:22:56 EST
libguestfs-1.30.5-2.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
$ su -c 'dnf --enablerepo=updates-testing update libguestfs'
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-943e9fb63b
Comment 19 Fedora Update System 2015-12-05 20:21:54 EST
libguestfs-1.30.5-2.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.
Comment 20 Fedora Update System 2015-12-16 04:53:10 EST
libguestfs-1.30.5-2.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.

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