Bug 715114

Summary: fdisk suggests creating extended partition of extremely small size < 1MB rather than a size of many GBs
Product: [Fedora] Fedora Reporter: Ken Fuchs <ken.fuchs>
Component: util-linuxAssignee: Karel Zak <kzak>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 15CC: jonathan, kzak
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Fedora 15 on Tunnel Creek SOC with Top Cliff chipset.
Last Closed: 2012-02-21 18:03:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Ken Fuchs 2011-06-21 21:49:52 UTC
Description of problem:

fdisk may suggest poor default values for the start of an extended (or primary) partition for a partition table made by an earlier version of fdisk or another program.

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

2.19.1-1.fc15

How reproducible:

start with this partition table definition:

# fdisk /dev/sda

Command (m for help): p

Disk /dev/sda: 64.0 GB, 64023257088 bytes
255 heads, 63 sectors/track, 7783 cylinders, total 125045424 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a3918

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63      524350      262144   83  Linux
/dev/sda2          524351    17301566     8388608   83  Linux
/dev/sda3        17303552    17827839      262144   83  Linux

#

In other words, start with a partially completed partition table missing one or more primary or its extended partition, created by an earlier version of fdisk or another program.  Add a primary or extended partition, accepting the default values suggested.

For example, 

Steps to Reproduce:
1. fdisk /dev/sda
2. n
3. e
4. Selected partition 4
   First sector (17301567-125045423, default 17301567): 
   Using default value 17301567
5. Last sector, +sectors or +size{K,M,G} (17301567-17303551, default 17303551): 
   Using default value 17303551
  
Actual results:

Command (m for help): p

Disk /dev/sda: 64.0 GB, 64023257088 bytes
255 heads, 63 sectors/track, 7783 cylinders, total 125045424 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a3918

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63      524350      262144   83  Linux
/dev/sda2          524351    17301566     8388608   83  Linux
/dev/sda3        17303552    17827839      262144   83  Linux
/dev/sda4        17301567    17303551         992+   5  Extended

Expected results:

An extended partition spanning from the end of partition 3 to the end of the disk.  A 992 sector = 496 KB extended partition between partition 2 and partition 3 should not be suggested, since it would very rarely be useful for creating logical partitions.

Additional info:

One could say that the fdisk functions correctly and it is operator error to accept the useless extended partition default addresses it provides, but it should be clear that when the user creates an extended partition, it should use by the default the largest free area as opposed to the smallest free area, especially when that smallest free area is not even 1MB in size.

Accepting the defaults also creates out of order partitions, which isn't necessarily bad, but isn't what the user or some programs might expect.

Comment 1 Karel Zak 2012-02-21 18:03:32 UTC
(In reply to comment #0)
> One could say that the fdisk functions correctly and it is operator error to
> accept the useless extended partition default addresses it provides, but it

The fdisk command is simple and stupid, and it's expected ;-)

> should be clear that when the user creates an extended partition, it should use
> by the default the largest free area as opposed to the smallest free area,
> especially when that smallest free area is not even 1MB in size.

It uses the first free area without care about partition type. In the "First sector" dialog you can select the right place and skip useless gaps.

Anyway, I have added a note about this issue to util-linux upstream TODO list. I think we can improve the dialog to make it more user friendly. We will see...

Thanks.