Re: Disk geometry from /sys

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Lennart Sorensen
Date: Wednesday, April 9, 2008 - 2:28 pm

On Wed, Apr 09, 2008 at 10:53:36PM +0200, Francis Moreau wrote:

Many compact flash cards will report 16 heads, and 16 or 32 sectors
per track.  Compact flash can of course connect as an IDE drive, so they
are worth supporting (I keep trying to get the grub guys to accept my
patch to fix their code that also assumed all disks have 63 sectors per
track if they use LBA, but which is false since compact flash also
supports LBA even with smaller sizes).

Simplest way to find out what geometry a disk pretents to have is to ask
fdisk, and since the only use for the information is when creating
partitions, then fdisk's opinion is really all that seems to matter.  Of
course partitions can start and end anywhere so the total size is
actually all that really matters.

For example:
# fdisk -l /dev/hda

Disk /dev/hda: 260 MB, 260571136 bytes
16 heads, 32 sectors/track, 994 cylinders
Units = cylinders of 512 * 512 = 262144 bytes

   Device Boot      Start         End      Blocks   Id  System
 /dev/hda1               1          40       10224   83  Linux
 /dev/hda2              41          80       10240   83  Linux
 /dev/hda3              81         994      233984   83  Linux

So no assuming 255 and 63 is not a good idea.  Large disks tend to do it
since 255 heads and 63 sectors per track is the maximum supported, and
hence allowed them to get as much space in each "cylinder".


Why do you want to know what cylinder size the hard disk pretents to
have?  What use could it be?  Harddisks have varying numbers of sectors
per cylinder depending on how far out you are from the center of the
disk, but since software used to expect a simple X head, Y tracks, Z
sectors per track, they lie about it and pretend to have some number of
each (usually 255 heads (as if), 63 sectors per track (not likely with
todays densities), and thousands of cylinders), and even with all that
added up it still works out to less than the actual size of a modern
drive.  All that matters on a modern drive is the total number of
sectors since all access is done by requesting a specific sector number
starting from the begining of the drive.  Where it is physically located
is none of software's business, and it may not even be adjacent to the
sector with a number right next to the requested one due to defect
management and various optimizations.

-- 
Len Sorensen
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Disk geometry from /sys, Francis Moreau, (Wed Apr 9, 1:53 pm)
Re: Disk geometry from /sys, Lennart Sorensen, (Wed Apr 9, 2:28 pm)
Re: Disk geometry from /sys, Alan Cox, (Wed Apr 9, 2:52 pm)
Re: Disk geometry from /sys, Mark Lord, (Wed Apr 9, 2:57 pm)
Re: Disk geometry from /sys, Bernd Eckenfels, (Wed Apr 9, 3:16 pm)
Re: Disk geometry from /sys, linux-os (Dick Johnson), (Thu Apr 10, 5:22 am)
Re: Disk geometry from /sys, Bill Davidsen, (Thu Apr 10, 6:58 am)
Re: Disk geometry from /sys, Lennart Sorensen, (Thu Apr 10, 7:52 am)
Re: Disk geometry from /sys, Francis Moreau, (Thu Apr 10, 12:05 pm)
Re: Disk geometry from /sys, Francis Moreau, (Thu Apr 10, 12:15 pm)
Re: Disk geometry from /sys, Francis Moreau, (Thu Apr 10, 12:23 pm)
Re: Disk geometry from /sys, Mark Lord, (Thu Apr 10, 12:53 pm)
Re: Disk geometry from /sys, Seewer Philippe, (Mon Apr 14, 5:57 am)
Re: Disk geometry from /sys, Francis Moreau, (Tue Apr 15, 12:40 am)
Re: Disk geometry from /sys, Seewer Philippe, (Wed Apr 16, 12:49 am)
Re: Disk geometry from /sys, Francis Moreau, (Thu Apr 17, 7:09 am)
Re: Disk geometry from /sys, Seewer Philippe, (Thu Apr 17, 7:49 am)
Re: Disk geometry from /sys, Mark Lord, (Fri Apr 18, 6:22 am)
Re: Disk geometry from /sys, Seewer Philippe, (Fri Apr 18, 6:37 am)
Re: Disk geometry from /sys, Francis Moreau, (Tue Apr 22, 1:10 pm)
Re: Disk geometry from /sys, Francis Moreau, (Tue Apr 22, 1:11 pm)
Re: Disk geometry from /sys, Francis Moreau, (Tue Apr 22, 1:16 pm)
Re: Disk geometry from /sys, Mark Lord, (Tue Apr 22, 3:44 pm)
Re: Disk geometry from /sys, Seewer Philippe, (Tue Apr 22, 11:44 pm)
Re: Disk geometry from /sys, Seewer Philippe, (Tue Apr 22, 11:48 pm)
Re: Disk geometry from /sys, Seewer Philippe, (Tue Apr 22, 11:53 pm)
Re: Disk geometry from /sys, Francis Moreau, (Tue Apr 22, 11:56 pm)
Re: Disk geometry from /sys, Francis Moreau, (Wed Apr 23, 12:02 am)
Re: Disk geometry from /sys, Seewer Philippe, (Wed Apr 23, 2:33 am)
Re: Disk geometry from /sys, Mark Lord, (Wed Apr 23, 6:47 am)