Bug 487227

Summary: fdisk doesn't handle large sectors properly
Product: [Fedora] Fedora Reporter: Eric Sandeen <esandeen>
Component: util-linux-ngAssignee: Karel Zak <kzak>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: kzak
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-03-19 14:11:52 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 463632, 614404, 618062, 696265    
Attachments:
Description Flags
potential patch none

Description Eric Sandeen 2009-02-24 21:31:32 UTC
fdisk (at least with the -u option) does not handle sector sizes other than 512 correctly:

# modprobe scsi_debug sector_size=4096 
# fdisk -u /dev/sdd
Note: sector size is 4096 (not 512)
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x4afdb02f.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (32-16383, default 32): 
Using default value 32
Last sector, +sectors or +size{K,M,G} (32-16383, default 16383): 
Using default value 16383

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
# dmesg | tail -n 2
 sdd: sdd1
sdd: p1 size 130816 limited to end of disk

# fdisk -l /dev/sdd
Note: sector size is 4096 (not 512)

Disk /dev/sdd: 8 MB, 8388608 bytes
8 heads, 32 sectors/track, 8 cylinders
Units = cylinders of 256 * 4096 = 1048576 bytes
Disk identifier: 0x4afdb02f

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1          64       65408   83  Linux

I think the only problem is that it is suggesting a default of last sector based on 512-byte sectors, not the 4k sectors.

I'll attach a patch that may be reasonable ...

-Eric

Comment 1 Eric Sandeen 2009-02-24 21:45:02 UTC
Created attachment 333094 [details]
potential patch

potential patch; made "sector_factor" a global, and use it in place of "sector_size/512"; also modify the limit in add_partition by this amount.

Comment 2 Karel Zak 2009-02-26 15:09:59 UTC
Applied to upstream tree.
http://git.kernel.org/?p=utils/util-linux-ng/util-linux-ng.git

I found some others places in util-linux-ng where is mess around hard sectors.

Thanks!