Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 199430 - mac-fdisk suggests wrong disk size on large devices
Summary: mac-fdisk suggests wrong disk size on large devices
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: PPC Porters
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-17 11:58 UTC by Robin Johnson
Modified: 2009-07-22 15:34 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Compute Disk Size Patch (compute.patch,363 bytes, patch)
2007-12-23 03:45 UTC, Joe Jezak (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2007-11-17 11:58:44 UTC
On disks larger than 512GiB, mac-fdisk suggests the wrong disk size.
The below is what happened when I was setting up my 750GB Hitachi disks.

livecd ~ # egrep 'name|sda' /proc/partitions                                                                                                                                                                                                                       
major minor  #blocks  name
   8     0  732574584 sda
=====
So that is in 1Kb blocks.
Now notice below how it suggests 1073741825 as the number of (512-byte) blocks on the device. That number is 30-bits, so I suspect the code is using a signed 32-bit integer somewhere, needs to be a 64-bit unsigned to be safe (I don't have any devices over 2TiB to test that on). It works fine once I tell it the correct number of blocks on the device, but this stuff might confuse some users.

livecd ~ # mac-fdisk /dev/sda                                                                                                                                                                                                                                      
/dev/sda
Command (? for help): p
No partition map exists
Command (? for help): i
size of 'device' is 1073741825 blocks: 
new size of 'device' is 1073741825 blocks
Command (? for help): p
/dev/sda
        #                    type name                   length   base       ( size )  system
/dev/sda1     Apple_partition_map Apple                      63 @ 1          ( 31.5k)  Partition map
/dev/sda2              Apple_Free Extra              1073741761 @ 64         (512.0G)  Free space

Block size=512, Number of Blocks=1073741825
DeviceType=0x0, DeviceId=0x0

Command (? for help): i
map already exists
do you want to reinit? [n/y]: y
size of 'device' is 1073741825 blocks: 1465149168
new size of 'device' is 1465149168 blocks
Command (? for help): p
/dev/sda
        #                    type name                   length   base       ( size )  system
/dev/sda1     Apple_partition_map Apple                      63 @ 1          ( 31.5k)  Partition map
/dev/sda2              Apple_Free Extra              1465149104 @ 64         (698.6G)  Free space

Block size=512, Number of Blocks=1465149168
DeviceType=0x0, DeviceId=0x0
Comment 1 Joe Jezak (RETIRED) gentoo-dev 2007-12-23 03:45:23 UTC
Created attachment 139155 [details, diff]
Compute Disk Size Patch

Can you please try this patch, then run mac-fdisk again?  It should print some debug info about how it determined the size of the disk.  Thanks!
Comment 2 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2007-12-23 05:23:14 UTC
# ./pdisk /dev/sdb

stat: mode = 060640, type=Block
size = 0, blocks = 0
BLKGETSIZE:size in blocks = 1465149168
HDIO_GETGEO: heads=255, sectors=63, cylinders=25665, start=0,  total=412308225
llseek to end of device failed on second try
/dev/sdb
Command (? for help): i
map already exists
do you want to reinit? [n/y]: y

stat: mode = 060640, type=Block
size = 0, blocks = 0
BLKGETSIZE:size in blocks = 1465149168
HDIO_GETGEO: heads=255, sectors=63, cylinders=25665, start=0,  total=412308225
llseek to end of device failed on second try
size of 'device' is 1073741825 blocks: 
new size of 'device' is 1073741825 blocks
Command (? for help): p
/dev/sdb
        #                    type name                   length   base       ( size )  system
/dev/sdb1     Apple_partition_map Apple                      63 @ 1          ( 31.5k)  Partition map
/dev/sdb2              Apple_Free Extra              1073741761 @ 64         (512.0G)  Free space

Block size=512, Number of Blocks=1073741825
DeviceType=0x0, DeviceId=0x0

Command (? for help): 
Comment 3 Joe Jezak (RETIRED) gentoo-dev 2009-07-22 15:34:51 UTC
This should be fixed in mac-fdisk-1.0.6-r7, but I think we're still limited to up to 2TB disks. I think this might be a limitation of the disk label, but I'm not 100% sure.