Bug 487227 - fdisk doesn't handle large sectors properly
fdisk doesn't handle large sectors properly
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: util-linux-ng (Show other bugs)
rawhide
All Linux
low Severity medium
: ---
: ---
Assigned To: Karel Zak
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 463632 614404 618062 696265
  Show dependency treegraph
 
Reported: 2009-02-24 16:31 EST by Eric Sandeen
Modified: 2011-04-13 13:57 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-03-19 10:11:52 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
potential patch (1.76 KB, patch)
2009-02-24 16:45 EST, Eric Sandeen
no flags Details | Diff

  None (edit)
Description Eric Sandeen 2009-02-24 16:31:32 EST
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 16:45:02 EST
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 10:09:59 EST
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!

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