lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 10 Apr 2008 08:22:48 -0400
From:	"linux-os (Dick Johnson)" <linux-os@...logic.com>
To:	"Francis Moreau" <francis.moro@...il.com>
Cc:	<linux-kernel@...r.kernel.org>
Subject: Re: Disk geometry from /sys


On Wed, 9 Apr 2008, Francis Moreau wrote:

> Hi,
>
> I'm trying to know the geometry of my hard disk from a bash script
> and that's the reason I'm looking in /sys. The reason is that I'd like
> to figure out the size of a cylinder without doing a
> ioctl(bdev, HDIO_GETGEO, &geo)
>
> Unfortunately I can't find anything useful and this is certainly a sign
> that I'm doing something wrong.
>
> Or maybe can I simply assume from my script that the geometry
> is always heads=255 and the number of sectors per track is 63 for all
> disks.
>
> Looking at parted(8) source code, I  can find this:
>
> /* The GETGEO ioctl is no longer useful (as of linux 2.6.x).  We could
> * still use it in 2.4.x, but this is contentious.  Perhaps we should
> * move to EDD. */
>
> Could anybody give me some advices ?
> -- 
> Francis
> --

It becomes, as you say contentious, because with disk drives
manufactured during the past ten or so years, anything about
the physical geometry is fictitious. The PC BIOS continues to
calculate C/H/S because that's what BIOS interrupt 0x13 uses
to boot the machine. The boot code needs to know what the
BIOS claims or else it may fail to boot. However, once Linux
is up, there are no C/H/S unless they were invented --and
hopefully, the same as what the BIOS claims.

In the BIOS interrupt 0x13 code, the maximum number of heads
that will fit in the register is 255. The maximum number of
sectors that will fit in the partial register scheme is 63.
That leaves the cylinders as the only remaining variable for
large media. However, the BIOS only needs to boot the machine.
There may be many more cylinders than your initial guess and
the BIOS can only use 10 bits of the cylinder number. If you
are writing boot code, perhaps making the next GRUB or whatever
then you can use the numbers you suggested. However if not, you
have no need to learn the actual disk geometry and it is not
even shown in many disk-drive data sheets because the number
of sectors on the outside tracks is now greater than the ones
on the inside tracks to maintain the same areal bit density and
maximize the storage capacity.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.22.1 on an i686 machine (5588.28 BogoMips).
My book : http://www.AbominableFirebug.com/
_


****************************************************************
The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@...logic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ