Last modified: Sun Jun 2 10:48:00 EDT 2019
Ways to prevent partitioning, formatting, and OS-installing software from being distracted by leftover junk on reused storage devices.
|dd 10 MB||Y||Y||Y||N||Y|
|dd whole drive||Y||N||Y||Y||Y|
|ATA Secure Erase||N||½||Y||Y||N|
In the details below,
/dev/sdx is a placeholder for whichever
device you want to clear.
blkdiscard /dev/sdx instructs an SSD to "trim" all of its
sectors. In my experience, it takes between 0 and 30 seconds, and
the effect is as if the drive had been zeroed out. This is, hands down,
the best option if the device supports it.
Zeroing out the first 10 megabytes, which normally takes out the partition
table and the beginning of the first partition, seems to get the job done and
is a great compromise when
blkdiscard doesn't apply.
dd if=/dev/zero of=/dev/sdx bs=1M count=10
wipefs will erase file system signatures from individual
partitions and the partition table signature from the partition table.
It changes the minimum number of bytes to make these things "invisible for
libblkid." This generally suffices if the software to follow is going
to be Linux, but otherwise not so much. For example, I had a problem
with W10 refusing to recognize a USB drive because it did not like the way it
was partitioned, and
wipefs didn't help. After dd 10 MB,
W10 recognized it as an empty drive.
wipefs -a /dev/sdx1
wipefs -a /dev/sdx2
wipefs -a /dev/sdx
Super-slow, but guaranteed to work.
dd if=/dev/zero of=/dev/sdx
In theory, ATA Secure Erase achieves the same thing as dd whole drive in a better and faster way. In practice, it's complicated to use, unreliable, and overkill if all you need is a clean install.