Bug 1249893

Summary: sfdisk: Clarification of "+" and "-" as size arguments
Product: [Fedora] Fedora Reporter: Ian Wienand <iwienand>
Component: util-linuxAssignee: Karel Zak <kzak>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 22CC: iwienand, jonathan, kzak
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-05 07:24:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
clarification for sfdisk man page none

Description Ian Wienand 2015-08-04 05:12:15 UTC
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 07:29:47 UTC
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-05 02:27:07 UTC
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 07:24:06 UTC
(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.