Problems finding drive size with ATA Identify
Page 1 of 1

Author:  SpaceDoge [ Tue May 11, 2021 1:55 am ]
Post subject:  Problems finding drive size with ATA Identify

A brief overview; I am using AHCI to write a driver and am currently stuck on trying to get the connected drives size. I can read and write to a drive, but it would be very helpful to know the size of the drive.

When I test my driver on real hardware with a 250GB drive the ATA identify command returns the max sector amount(137GB) as if it is a 28-bit LBA drive. And this is returned in words 230-233 "extended # of user addressable sectors" not in the 28-bit sector amount words(60-61). Also the 28-bit sector amount words(60-61) show 0x0007000. The last place for sector amount(100-103) shows 0. I know my drive has 48-bit support and the BIOS confirms this by showing the proper drive size. Also the drive was in this laptop before and completely functional in a Windows Vista installation.

The other interesting thing is that I noticed is the "48-bit address feature set is supported" bit in word 83 is set but the "48-bit address feature set is supported" in word 86 is not set. To me this means that it is supported but not enabled since 83 is labeled as features supported and 86 is labeled as features enabled.

I couldn't find any information about enabling 48-bit lba and decided to just ask this question on here. Does anyone know if there is a way to enable 48-bit lba or does anyone have an idea of what might be going on here?

Author:  Octocontrabass [ Tue May 11, 2021 8:50 pm ]
Post subject:  Re: Problems finding drive size with ATA Identify

There's no way to disable 48-bit LBA. If the drive supports it, it's always enabled. My guess is it's some kind of memory corruption bug, since those values are all nonsense.

Have you tried dumping the whole IDENTIFY DEVICE data and comparing against what you see in another OS? (Using hdparm --Iraw/--Istdin under Linux, for example.)

Author:  SpaceDoge [ Wed May 12, 2021 3:02 am ]
Post subject:  Re: Problems finding drive size with ATA Identify

Thank you for the hdparm tip, I did not know about it. When running it I do get the correct number for everything.

I compared it's raw output to my raw output and they match exactly except for a couple nibbles that were slightly different. I think my structure must either be messed up or I am indexing words incorrectly.

Either way thank you so much showing me how to see the expected data compared to what I get. I think I can solve this issue now.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group