Bug 1183234 - sfdisk does not allow changing the partition type to unknown types
Summary: sfdisk does not allow changing the partition type to unknown types
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: util-linux
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: TRACKER-bugs-affecting-libguestfs
TreeView+ depends on / blocked
 
Reported: 2015-01-17 13:48 UTC by Richard W.M. Jones
Modified: 2015-02-11 09:23 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-02-11 09:23:12 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Richard W.M. Jones 2015-01-17 13:48:15 UTC
Description of problem:

sfdisk has changed its command line, so now running this test
(or using the guestfs_part_set_mbr_id API) fails with:

libguestfs: trace: part_set_mbr_id "/dev/sda" 1 127
05 seconds
guestfsd: main_loop: new request, len 0x3c
udevadm --debug settle
calling: settle
sfdisk --change-id /dev/sda 1 7f
sfdisk: change-id is deprecated in favour of ---part-type
sfdisk: --id s deprecated in favour of ---part-type
sfdisk: failed to parse dos partition type '7f'
[    2.592464]  sda: sda1
guestfsd: error: sfdisk --change-id: sfdisk: change-id is deprecated in favour of ---part-type
sfdisk: --id s deprecated in favour of ---part-type
sfdisk: failed to parse dos partition type '7f'
guestfsd: main_loop: proc 236 (part_set_mbr_id) took 0.01 seconds
libguestfs: trace: part_set_mbr_id = -1 (error)
libguestfs: error: part_set_mbr_id: sfdisk --change-id: sfdisk: change-id is deprecated in favour of ---part-type
sfdisk: --id s deprecated in favour of ---part-type
sfdisk: failed to parse dos partition type '7f'
FAIL: test_part_get_mbr_id_0

A simple one-line reproducer is:

$ guestfish -N fs part-set-mbr-id /dev/sda 1 127
libguestfs: error: part_set_mbr_id: sfdisk --change-id: sfdisk: change-id is deprecated in favour of ---part-type
sfdisk: --id s deprecated in favour of ---part-type
sfdisk: failed to parse dos partition type '7f'

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

libguestfs-1.29.20

However the problematic package is sfdisk:
util-linux-2.26-0.2.fc22.x86_64

How reproducible:

100%

Steps to Reproduce:
1. guestfish -N fs part-set-mbr-id /dev/sda 1 127

Comment 1 Richard W.M. Jones 2015-01-17 13:49:36 UTC
I have skipped this test in Rawhide for now.

Comment 2 Pino Toscano 2015-01-28 08:33:06 UTC
Aside the deprecated command line option (which is easy to switch to the new option), the real problem here is that the new sfdisk in util-linux 2.26 reject unknown partition types, hence the "7f" triggers an error:

  151: libfdisk: PARTTYPE: [0x1f0b5d0]: returns parsed 'unknown' partition type
  sfdisk: failed to parse dos partition type '0x7f'

(when enabling debug, i.e. exporting SFDISK_DEBUG=all and LIBFDISK_DEBUG=all)

While this can make sense, because for older partition types there are really no unknown partition types, on the other hand it might be useful to force a partition type which libsfdisk does not known about (say a new gpt type).

Comment 3 Karel Zak 2015-01-28 09:01:49 UTC
(In reply to Pino Toscano from comment #2)
> Aside the deprecated command line option (which is easy to switch to the new
> option), the real problem here is that the new sfdisk in util-linux 2.26
> reject unknown partition types, hence the "7f" triggers an error:
> 
>   151: libfdisk: PARTTYPE: [0x1f0b5d0]: returns parsed 'unknown' partition
> type
>   sfdisk: failed to parse dos partition type '0x7f'

This is bug. Fixed by upstream commit aaa0ba88b4afd328e13e9dd79a0df99d7fb76fbd.

	# sfdisk --part-type /dev/sdb 1 0x7f

	The partition table has been altered.
	Calling ioctl() to re-read partition table.
	Syncing disks.


	# sfdisk --list /dev/sdb
	Disk /dev/sdb: 100 MiB, 104857600 bytes, 204800 sectors
	Units: sectors of 1 * 512 = 512 bytes
	Sector size (logical/physical): 512 bytes / 512 bytes
	I/O size (minimum/optimal): 512 bytes / 32768 bytes
	Disklabel type: dos
	Disk identifier: 0x941f0074

	Device     Boot Start    End Sectors Size Id Type
	/dev/sdb1        2048  22527   20480  10M 7f unknown
	/dev/sdb2       22528 204799  182272  89M  c W95 FAT32 (LBA)


Thanks! (Fedora package will be updated ASAP (after -rc2 release).)


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