Safely deleting a drive with LUKS

It can be very fast to safely delete a drive using encryption. The idea is basically to encrypt the whole disk and afterwards to overwrite it with zeros. In this article, I use LUKS, which already ships with Ubuntu 14.04. This procedure may be quicker and more reliable than “copy-based” methods if your CPU supports crypto commands.

First, replace all partitions that should be safely deleted with one large unformatted partition. I assume that this partition is called /dev/sda1 . Afterwards, setup LUKS on the unformatted partition. The password may be a really simple one.

sudo cryptsetup -c aes-xts-plain64 -s 512 luksFormat /dev/sda1

Now, open the encrypted volume, entering the same password:

sudo cryptsetup luksOpen /dev/sda1 lukslvm

Afterwards, you start writing zeros into the encrypted partition, which will produce more or less random data on the disk:

sudo dd if=/dev/zero of=/dev/mapper/lukslvm bs=1M

 

Leave a Reply