Why do "Reallocated Sector Count" and relevant counts become zero
after Secure Erase? Does this mean that there are no real badblock and
it is due to incorrect reading of SMART?
According to several drive manufacturer documents, Secure Erase targets reallocated sectors, example:
" Enhanced Erase mode, all previously
written user data shall be overwritten,
including sectors that are no longer in use
due to reallocation.” - source.
SMART values for reallocated sectors reflects the grown defects list (G-List). So sectors that are found to be 'bad' after the hard drive left the factory are moved to the G-List and these are published via SMART (reallocated sectors count).
Indeed a sector may turn out to be good after re-examining it during a secure erase. For example due to vibration a drive may be unable to locate a sector which is normally a serious error and thus reallocation worthy, or read it after significant error recovery and such a sector may be reallocated on-the-fly. If the sector is re-tested during a secure erase and reads without issue it can be put back in service.
It might possible drives themselves move G-List sectors to the P-List. I don't have direct evidence supporting this however I do know certain drive brand and models support the so called "format unit" command. This is a vendor specific command (so not part of some standardized spec. like ATA) that erases user data and 'merges' the G en P lists:
"The Format Unit command initializes all user data sectors after merging reassigned sector location into the defect information of the device and clearing the reassign information. Both new reassign information and new defect information are available right after command completion of this command. Previous information of reassign and defect are erased from the device by executing this command."
What I therefore think that could be happening in certain models during a Secure Erase is sectors that can not be 'repaired' are moved from the G-List to the P-List and SMART 'reallocated sectors count' reflects the now empty G-List. IOW, a drive may do a format unit procedure when Secure Erase command is received.
I again must stress I am speculating here.
If these counts underestimate the real number of badblocks, how can I
read the correct number of badblocks after a Secure Erase?
You can normally not read the 'correct' number of bad blocks, the hard drive manufacturer decides what the drive publishes. What SMART shows you are grown defects, not bad blocks already detected during the manufacturing. However tools do exist, exploiting vendor specific commands, that have access to the P-List.
dd if=/dev/zero
), norsmartctl -t long
would detect and remap bad sectors?fsck
invokesbadblocks
, which is simply performing read/write tests sector by sector, and mark all sectors with I/O errors. However, I heard that "modern" HDD's hide bad sectors in that, during an access to a bad sector, from the outside it looks like reading or writing the same sector but internally remapped to another, so the outsider no longer "knows" that this is a bad sector. I am trying to understand whether these SMART counts record the number of these internally remapped sectors, say.