/! Look for Update 2 down there, the question is half-answered now /!
I sometimes completely wipe my hard drives (not SSDs); being what they are, dd and badblocks -w do wipe everything blindlessly.
The thing is, they are also writing hard drives’ spare sectors, which is bad since they are all brand new.
So if something do happen during the erasure process (power loss, write errors, etc), that would kill a very useful sector… for nothing.
So the question is: How to avoid dd or badblocks erasing hard drives’ spare sectors ?
- dd is known to blindlessly erase everything that goes through it.
- badblocks is known to be able to access unmapped blocks.
dd definitely can’t access spare sectors if they didn’t replaced a faulty sector (obviously).
This is due to how dd was designed (answer by Kamil Mociorowski):
The logical sector numbers available to dd are mapped to numbered
physical sectors and the corresponding numbers are initially equal.
Spare physical sectors initially have no logical numbers assigned, so
dd cannot reach them.
Being mostly a sysadmin -and not being a “close to low-level” coder (C)-, can someone take a look at badblocks’ code and tell if it does access spare sectors ?
To be more precise, does badblocks also take into account spare sectors inside its blocks readings/writings ?
On another side/way to get the answer; I also know that Theodore Ts’o, the badblocks’ maintainer, do comes here on superuser.
If he reads this update 2, is it possible to have a direct answer about that ?