On an SSD: You can TRIM whole disks or partitions using blkdiscard
. It's not very secure, but practically instant (the disk merely marks all cells as unused).
For SATA SSDs, the ATA "Secure Erase" command (available through hdparm
) is also very fast. There is also "Enhanced Secure Erase", which (at least on the SSDs I've used it on) takes a few seconds longer and appears to physically erase all cells.
For security: Use full-disk encryption. Don't bother wiping the entire disk if it's encrypted – you only need to wipe the area containing your keys (e.g. the first 1–2 MiB of every encrypted partition).
For repartitioning: Again, don't bother erasing all data. You only need to destroy the filesystems using wipefs
, then scrub the first 1 MiB of your disk to purge leftover bootloaders. After you format a partition using mkfs
, the OS will simply assume it is completely empty.
(In fact, on Linux, mkfs.ext4 will automatically TRIM the entire partition before formatting it.)