I usually use
# pv -terab /dev/zero > /dev/sdx
to zero a disk (ie: /dev/sdx). Basically, it just writes zero everywhere without caring of the previous values.
However, I'm wondering if it wouldn't be faster, especially on USB flash drive, to read the disk and only IF the read value is different from zero, then set it to zero. How can I do that? Especially in a bash single command line.
The interest I get on that is that USB flash drive have several specificities. They are read quite quickly but written quite slowly. They tends to wear for too much writing. Last point, as far as I know, it is not possible to use efficiently the command "trim" on them.
Therefore writing only on the data of the disk that are not already set to zero should be worthy...
Thank you for answers.
PS: sorry for bad english, not my native language