Get Hard Disk Drive Max Heads And Cylinders

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
ahmedhalawa
Member
Member
Posts: 28
Joined: Wed Jul 02, 2008 9:28 am

Get Hard Disk Drive Max Heads And Cylinders

Post by ahmedhalawa »

How can i get hard disk maximum heads and maximum cylinders?
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Get Hard Disk Drive Max Heads And Cylinders

Post by Troy Martin »

Read the MBR. It's usually in there, just look for the last block of the last used partition.

Then again, this only works if every chunk of the hard drive is partitioned.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: Get Hard Disk Drive Max Heads And Cylinders

Post by pcmattman »

Use the ATA IDENTIFY DEVICE command.
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: Get Hard Disk Drive Max Heads And Cylinders

Post by quok »

Troy Martin wrote:Read the MBR. It's usually in there, just look for the last block of the last used partition.

Then again, this only works if every chunk of the hard drive is partitioned.
And it fails entirely if the MBR uses LBA instead of CHS, or for GPT partitioned drives.

A better solution:
  • Int 13h AH=08h -- Get Drive Parameters
  • Int 13h AH=48h -- Get Extended Drive Parameters
Of course those only work in real mode (or vm86 mode), but it's perhaps the best way to get that information without having to worry if the drive is ATA, ATAPI, SATA, SATAPI, or SCSI.

For a little more information: http://en.wikipedia.org/wiki/INT_13
Post Reply