How can I change a SMART attribute value?
I have a drive which has signaled a SMART error (Current_Pending_Sector
is 1
) and I've run a "long offline test" against the drive which reported zero errors.
This was after running a "short offline test", identifying an unreadable sector, forcing its relocation and re-building a software RAID device with this drive as one of the members. I'm fairly sure the drive is clean at this point.
Is there a way I can clear-out that 1
value for Current_Pending_Sector
? The manual page for smartctl
doesn't seem to mention how to change attribute values. Is this possible, or is SMART essentially read-only?
Solution 1:
SMART is essentially read-only.
You would change the value by fixing the underlying issue and allowing the drive to self-resolve it (if it can!)
From a similar question, "How should I understand 'Current Pending Sector Count'
Later, when some of these sectors are read successfully, the value is decreased.
Note the two things that need to happen:
- The sector must be read
- The read must succeed
If the hard drive sector has sustained permanent damage that number will never drop back to zero. I like to replace hard drives when that happens and let the redundancy from their RAID array or mirroring setup resolve that issue.
Solution 2:
SMART values are read-only, unless you have the access to the tools specific for the vendor your particular drive.
Also take a look at this question answer.
Solution 3:
The accepted answer is incorrect - pending sector count will drop to 0 once the pending sector is resolved, and resolution is guaranteed to happen eventually. (It is called 'pending' for a reason!) This can happen either via a subsequent successful read (unlikely), or when the sector is written to. When it is written to, either the write will succeed, or it will fail harmlessly and the sector will be reallocated. In any case, it will no longer be a pending sector.
To accelerate this process, you can manually overwrite the sector. The safest way to do so is to identify the file containing the bad sector (filesystem dependent process), and then overwrite the file (non-CoW filesystem) or zerofill all free space (CoW filesystem). If you are feeling particularly brave or don't care about the filesystem, you can overwrite the sector directly with hdparm. There is a good explanation of how to do so here: How to use hdparm to fix a pending sector?