Bug 1183236 - sfdisk: unssupported unit 'M'
Summary: sfdisk: unssupported unit 'M'
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 14:21 UTC by Richard W.M. Jones
Modified: 2015-03-03 09:52 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-03 09:52:56 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Richard W.M. Jones 2015-01-17 14:21:27 UTC
Description of problem:

libguestfs invokes sfdisk to get some partition information
from MBR partitions.  Since about a month ago, we've started
to see this error:

sfdisk -uM /dev/sda
sfdisk: unssupported unit 'M'

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

Broken in util-linux-2.26-0.2.fc22.x86_64
(I'm not exactly clear when it worked, but recently)

How reproducible:

100%

Steps to Reproduce:
1. See above.

Comment 1 Karel Zak 2015-01-19 09:51:04 UTC
(In reply to Richard W.M. Jones from comment #0)
> Description of problem:
> 
> libguestfs invokes sfdisk to get some partition information
> from MBR partitions.  Since about a month ago, we've started
> to see this error:

well, we have v2.26 in Fedora since last Friday :-)

> sfdisk -uM /dev/sda
> sfdisk: unssupported unit 'M'
> 
> Version-Release number of selected component (if applicable):
> 
> Broken in util-linux-2.26-0.2.fc22.x86_64
> (I'm not exactly clear when it worked, but recently)

since v2.26, sfdisk supports -uS only. No cylinders, no megabytes are supported. The column SIZE is always in human readable {M,G,P...}iB units.

Anyway, old version has no clue about another sector sizes than 512, so I guess the output has been wrong in some cases. The new version provides ability to specify output columns (e.g. -o DEVICE,START,END,SIZE) to make it more usable in scripts.

I'll try improve -u to accept also 'M'.

Comment 2 Karel Zak 2015-01-19 10:31:01 UTC
Hmm.. old "sfdisk -uM" prints also Start and End offsets in megabytes (rather than in sectors). I don't plan to support such crazy thing. 

It seems better to keep -uM unsupported at all than implement only fractional part of the original -uM functionality.

I have added --bytes to fdisk and sfdisk to print SIZE column in bytes (we use the same for another tools,e.g. lsblk).

Please, update your sfdisk call to not use -uM.

BTW, for what purpose you call sfdisk?

Comment 3 Richard W.M. Jones 2015-01-19 14:33:35 UTC
(In reply to Karel Zak from comment #2)
> Hmm.. old "sfdisk -uM" prints also Start and End offsets in megabytes
> (rather than in sectors). I don't plan to support such crazy thing. 
> 
> It seems better to keep -uM unsupported at all than implement only
> fractional part of the original -uM functionality.
> 
> I have added --bytes to fdisk and sfdisk to print SIZE column in bytes (we
> use the same for another tools,e.g. lsblk).
> 
> Please, update your sfdisk call to not use -uM.
> 
> BTW, for what purpose you call sfdisk?

It's to support a long-deprecated API:

http://libguestfs.org/guestfs.3.html#guestfs_sfdiskm

We don't drop deprecated APIs, and therefore would need to
emulate the old behaviour, no matter how crazy it might have been.

Looking more closely at the libguestfs code, we're not wanting
this to print the partitions.  We want it for creating partitions,
which IMHO seems not crazy at all.  ie.

sfdisk -uM /dev/sda <<EOF
,127
128,
EOF

In fact, it seems quite a reasonable thing to do if you wanted
a partition of size 128 MB.

Comment 4 Karel Zak 2015-01-19 16:54:40 UTC
New sfdisk allows to specify size of the partition by {M,G,...}[iB] suffixes

 # sfdisk /dev/sdb <<EOF
 ,128M
 EOF

of course if you want to specify Start/End sectors then you have to use sectors numbers without any suffix (but it's usually unnecessary -- the next partition starts after the previous by default).

Comment 5 Richard W.M. Jones 2015-01-19 16:56:14 UTC
One of the reasons we deprecated guestfs_sfdiskM was it had a
terrible API.  In this case, it exposed the actual input of
sfdisk as an API ...  We live and learn.

Comment 6 Karel Zak 2015-01-19 17:40:16 UTC
Now when I think about it ... I'll probably extend the parser used for sfdisk scripts to accept suffixes for Start/End sectors. It seems usable if you want to create gaps between partitions or you want to define a special offset for the first partition.

Frankly, old sfdisk is unmaintained for very long time, it's useless for new disks etc. It's recommended to not use it.

I hope the new sfdisk is more usable for humans, the nice advantage is that all is implemented in libfdisk (so for example scripts in sfdisk scripts is possible to use in cfdisk and fdisk too), and now we can maintain all the fdisk(s) together and share all the functionality. And finally it's not about MBR only, it supports GPT too.

(and yes, I understand that this change is painful for users...)

Comment 7 Karel Zak 2015-03-03 09:52:56 UTC
(In reply to Karel Zak from comment #6)
> Now when I think about it ... I'll probably extend the parser used for
> sfdisk scripts to accept suffixes for Start/End sectors.

Implemented in v2.26


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