Bug 1249893 - sfdisk: Clarification of "+" and "-" as size arguments
sfdisk: Clarification of "+" and "-" as size arguments
Status: CLOSED NEXTRELEASE
Product: Fedora
Classification: Fedora
Component: util-linux (Show other bugs)
22
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Karel Zak
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-04 01:12 EDT by Ian Wienand
Modified: 2015-08-05 03:24 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-08-05 03:24:06 EDT
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)
clarification for sfdisk man page (3.54 KB, patch)
2015-08-04 22:27 EDT, Ian Wienand
no flags Details | Diff

  None (edit)
Description Ian Wienand 2015-08-04 01:12:15 EDT
The man page says

"The default value of size is as much as possible (until the next partition or end-of-device).  A '+' can be used instead of a number for size, which also means as much as possible."

However the source is setting FDISK_RESIZE_ENLARGE when you use a '+' for size; something not done for the default case? [1]

I can't find any difference between the "+" and "-" in some empirical testing, but it would be good to clarify what's going on. 

[1] https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/libfdisk/src/script.c#n1050
Comment 1 Karel Zak 2015-08-04 03:29:47 EDT
The "-" has no any meaning, it's just place-holder to support formats without delimiters, like "2048 - L *". Note that "-<num>" means reduce size.

The unspecified size field means "follow the label driver default" -- it's usually all available space for a new partition.

The "+" calls generic resize code if used for *already existing partition*, if the partition does not exist then it's the same as the previous case (driver default).

For example:

 2048 , , L
 2048, -, L
 2048, +, L

all have the same meaning, for empty disk, but

 echo "2048, +, L" | sfdisk -N 1 /dev/sdb

enlarge the first partition (-N 1) as much as possible.

So, it depends on context, for empty disks where you create a new partitions (fdisk_add_partition()) it's always driver default, for existing partition it's about resizing (fdisk_set_partition()).

Note that the parser in the script.c has no clue about the current disk layout, it's the reason why it sets fdisk_partition_end_follow_default() as well as FDISK_RESIZE_ENLARGE for alone "+". The final interpretation depends on used function (fdisk_{add,set}_partition()).

Please, close if you have enough information :-) Thanks.
Comment 2 Ian Wienand 2015-08-04 22:27:07 EDT
Created attachment 1059296 [details]
clarification for sfdisk man page

Thank you for the info.  Do you think something like the attached patch might help clarify the sfdisk man page?
Comment 3 Karel Zak 2015-08-05 03:24:06 EDT
(In reply to Ian Wienand from comment #2)
> Do you think something like the attached patch
> might help clarify the sfdisk man page?

Applied, thanks.

https://github.com/karelzak/util-linux/commit/11aa2aa290d2d654d621bd4729b535234480734b

The change will be available in f23.

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