How do you securely erase remapped bad sectors on HDD in Linux?

2

1

I have run badblocks on my HDD in Linux. No badblocks were found. However some bad sectors may have been previously detected and remapped; if this is the case, the badblocks test would not have found anything. Is it possible for me to securely erase those bad sectors, if there are any?

user138072

Posted 2016-12-28T02:41:54.383

Reputation: 101

You want to be able to use the disk afterwards, or not? Destroying the data with the disk is quite straightforward. Keeping the disk alive is a more difficult proposition. – Ecnerwal – 2016-12-28T03:09:38.260

I definitely plan on keeping it. I just want to wipe all old data for security reasons. – user138072 – 2016-12-28T03:26:48.097

Is there no command or program I can use to access remapped bad sectors? If doing such a thing is impossible from the OS, then I'll move on. – user138072 – 2016-12-28T04:04:24.060

I don't know if there is such a command, off the top of my head. When there has been a security concern with old data at my workplaces, the price of the hard-drive was not a concern and physical destruction was and is the approach we have taken and do take. Someone else may know a method, or not. Give it some time. – Ecnerwal – 2016-12-28T04:08:46.903

I don't believe this is possible with normal software. It may be possible with special software used by data recovery professionals. The cost for such is out of reach for normal users. If you are that concerned about security physical destruction is probably a better option. – LMiller7 – 2016-12-28T04:38:23.747

To clarify, I am not concerned about it to such a degree that I would destroy the hard drive. In fact I'd probably be fine leaving it as it is. But I saved data to the drive unencrypted. Hence if securely erasing that data (if bad sectors have been remapped - I don't know if they have or have not) is possible in Linux, then I'd like to know. I'll wait for more responses... – user138072 – 2016-12-28T05:32:13.977

Answers

1

You can check if there were sectors reallocated with smartctl (look at Reallocated_Sector_Count, the last column is the raw value).

If your harddisk supports the security feature set, you can issue a SECURITY ERASE UNIT command in enhanced erase mode, which will also erase reallocated user data (see p. 215). However, this command will also erase all other data.

The tool hdparm can be used to perform such an erase.

I'm not aware of any standardized protocol to get a list of reallocated sectors from a harddisk, or to access the reallocated sectors directly (after all, they are reallocated, so they don't have any LBN associated with them anymore).

dirkt

Posted 2016-12-28T02:41:54.383

Reputation: 11 627

Tried installing "smartctl". Said it cold not because it has no installation candidate. Looked it up in the Software Manager and found 'gsmartcontrol'. Ran it with 'sudo gsmartcontrol' > right clicked my drive > clicked 'View details' > clicked Attributes heading > viewed 'Reallocated Sector Count' row. The following details have a 'column heading: value' relationship. Failed: Never. Norm-ed value: 100. Worst: 100. Threshold: 5. Raw value: 0. Type: pre-failure. Updated: continuously. Flag: 0x0033. This has me confused. Does this mean NO bad sectors have been found? It says 'pre-failure'. – user138072 – 2016-12-29T02:18:31.430

Pre-failure sounds bad to me. In fact, all rows for "Type" say 'pre-failure' or 'old age'. This has me confused. The overall Health Self-Assessment Test is 'PASSED'. I'm assuming those heading names are cryptic and do not mean exactly what they first appear to mean. Am I to assume that my HDD is fine and no bad sectors have been found? – user138072 – 2016-12-29T02:21:24.253

1"Pre-failure" and "old-age" is just the class this measurements falls into. And yes, smartctl is used to monitor the drive to detect failure and old age. If there's lots of sectors reallocated, that means there's lots of bad sectors detected, which means your drive is about to fail completely, and it's time for a backup and a new one. Raw value "0" means there was no sector reallocated so far ("100% good" as normalized value), so your HDD is fine, hasn't found any bad sectors so far, and you don't need to erase them. – dirkt – 2016-12-29T09:50:37.727