[PLUG] Is fdisk/sfdisk lying to me?

linux-yug linux-yug at xprt.net
Tue Oct 27 05:49:23 UTC 2009


On Mon, 2009-10-26 at 21:31 -0700, William A Morita wrote:
> Is "fdisk" or "sfdisk" lying to me? Or both?
> 
> Below is the output of both "fdisk" and "sfdisk".  Nobody makes sense.
> 
> Both claim the different geometry (heads, sectors/track) and a differing
> number of cylinders.
> Yet both pretty much agree on the ending cylinder of sda1.
> With the number of heads disagreeing, almost nothing should line up. 
> 
> fdisk
> -----
> fdisk claims cylinders are made up of 15120 blocks of 512 bytes yielding
> 7741440 bytes per cylinder.
> Yet, doing a cylinder computation of sda1 gives:
> Blocks/(blocks/cylinder) 51309688/15120 = 3393.49 
> (Because some partitions start/stop on non-cylinder boundaries fractions are
> expected here)
> This value is half the expected value of 6786.
> If a block is actually 1024 bytes (as sfdisk claims and bytes per cylinder
> still 7741440) 
> then the blocks per cylinder would be 7560 making the computation:
> 51309688/7560 = 6786.99
> which is the about the expected value.
> 
> sfdisk
> ------                                   
> sfdisk claims cylinders are made up of 8225280 bytes in blocks of 1024 bytes
> (yielding 8032.5? blocks per cylinder).
> This looks line the number of bytes per cylinder is off by half a block.
> Cylinder size in bytes and in blocks should be consistent with each other.
> 
> Anybody got an idea of what is going on here?
> Am I doing the computations wrong?
> 
>  
> # fdisk -l /dev/sda
> 
> Disk /dev/sda: 250.0 GB, 250059350016 bytes
> 240 heads, 63 sectors/track, 32301 cylinders
> Units = cylinders of 15120 * 512 = 7741440 bytes
> 
>    Device Boot      Start         End      Blocks   Id  System
> /dev/sda1   *           1        6787    51309688+   7  HPFS/NTFS
> /dev/sda2           31334       32301     7318080    7  HPFS/NTFS
> /dev/sda3            6788        8142    10243800   83  Linux
> /dev/sda4            8143       31333   175323960    f  W95 Ext'd (LBA)
> /dev/sda5            8143        8420     2101648+  82  Linux swap / Solaris
> /dev/sda6            8421       11129    20480008+  83  Linux
> /dev/sda7           11130       13838    20480008+  83  Linux
> /dev/sda8           13839       19256    40960048+  83  Linux
> /dev/sda9           19257       24674    40960048+  83  Linux
> 
> Partition table entries are not in disk order
> # sfdisk -lq /dev/sda
> 
> Disk /dev/sda: 30401 cylinders, 255 heads, 63 sectors/track
> Warning: extended partition does not start at a cylinder boundary.
> DOS and Linux will interpret the contents differently.
> Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
> 
>    Device Boot Start     End   #cyls    #blocks   Id  System
> /dev/sda1   *      0+   6387-   6388-  51309688+   7  HPFS/NTFS
> /dev/sda2      29489+  30400-    912-   7318080    7  HPFS/NTFS
> /dev/sda3       6387+   7663-   1276-  10243800   83  Linux
> /dev/sda4       7663+  29489-  21827- 175323960    f  W95 Ext'd (LBA)
> /dev/sda5       7663+   7924-    262-   2101648+  82  Linux swap / Solaris
> /dev/sda6       7924+  10474-   2550-  20480008+  83  Linux
> /dev/sda7      10474+  13023    2550-  20480008+  83  Linux
> /dev/sda8      13024+  18123-   5100-  40960048+  83  Linux
> /dev/sda9      18123+  23222-   5100-  40960048+  83  Linux
> 
> # For those that want disk ordering of the partitions
> # fdisk -l /dev/sda  | tr '*+-' '   ' | grep ^/dev | sort -nk 2
> /dev/sda1               1        6787    51309688    7  HPFS/NTFS
> /dev/sda3            6788        8142    10243800   83  Linux
> /dev/sda4            8143       31333   175323960    f  W95 Ext'd (LBA)
> /dev/sda5            8143        8420     2101648   82  Linux swap / Solaris
> /dev/sda6            8421       11129    20480008   83  Linux
> /dev/sda7           11130       13838    20480008   83  Linux
> /dev/sda8           13839       19256    40960048   83  Linux
> /dev/sda9           19257       24674    40960048   83  Linux
> /dev/sda2           31334       32301     7318080    7  HPFS/NTFS
> 
> FYI: the disk was partitioned using Partition Magic
> 
> - Bill Morita
> wamorita At hevanet.com
> 
> 




As with everything 

YMMV..

What fdisk and sfdisk report is just something to make the user happy.
Data in not stored on modern disk in cyl/head/sector 

For example...Do you really believe you have 255 heads on your drive?

So why does it say that...?  Survey says...in the bios field on the
drive you have room for an 8 bit number... 

C * H * S  should give you disk size...

At some point in time we started using LBA  <Logical Block Addressing>
Which means..We tell the user we are storing data one place and actually
store it some other place...

And it goes on and on...  There are probably  A LOT of people who can
explain this better then I....   I will leave that up to them..

What is the problem you are trying to solve?
Or are you just curious about the disk size?
Or it is a SLOW NIGHT?

And of course there is the difference between base10 and base2 and base8
and base16 numbers..

HTH

Linux-yug..








> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
> 




More information about the PLUG mailing list