Here are some notes on how to securely delete computer data in a way that makes it impractical for anybody to recover that data. This is an important thing to do before giving away (or throwing away) old disks.
Ideally though, it's better not to have to rely on secure erasure and start use full-disk encryption right from the start, for example, using LUKS. That way if the secure deletion fails for whatever reason, or can't be performed (e.g. the drive is dead), then it's not a big deal.
Rotating hard drives
With ATA or SCSI hard drives, DBAN seems to be the ideal solution.
- Burn it on CD,
- boot with it,
- and following the instructions.
Note that you should disconnect any drives you don't want to erase before booting with that CD.
This is probably the most trustworth method of wiping since it uses free and open source software to write to each sector of the drive several times. The methods that follow rely on proprietary software built into the firmware of the devices and so you have to trust that it is implemented properly and not backdoored.
ATA / SATA solid-state drives
Due to the nature of solid-state storage (i.e. the lifetime number of writes is limited), it's not a good idea to use DBAN for those. Instead, we must rely on the vendor's implementation of ATA Secure Erase.
First, set a password on the drive:
hdparm --user-master u --security-set-pass p /dev/sdX
and then issue a Secure Erase command:
hdparm --user-master u --security-erase-enhanced p /dev/sdX
If you get errors like "bad/missing sense data", then you may need to use one of the tricks described in this thread. For me, suspending the laptop and then waking it up did the trick.
NVMe solid-state drives
For SSDs using an NVMe connector, simply request a User Data Erase
nvme format -s1 /dev/nvme0n1
Similarly to what I wrote for Debian stretch and jessie, here is how I was able to create a Fedora 29 LXC container on an Ubuntu 18.04 (bionic) laptop.
Setting up LXC on Ubuntu
First of all, install lxc:
apt install lxc
echo "veth" >> /etc/modules
modprobe veth
turn on bridged networking by putting the following in
/etc/sysctl.d/local.conf
:
net.ipv4.ip_forward=1
and applying it using:
sysctl -p /etc/sysctl.d/local.conf
Then allow the right traffic in your firewall
(/etc/network/iptables.up.rules
in my case):
# LXC containers
-A FORWARD -d 10.0.3.0/24 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -s 10.0.3.0/24 -j ACCEPT
-A INPUT -d 224.0.0.251 -s 10.0.3.1 -j ACCEPT
-A INPUT -d 239.255.255.250 -s 10.0.3.1 -j ACCEPT
-A INPUT -d 10.0.3.255 -s 10.0.3.1 -j ACCEPT
-A INPUT -d 10.0.3.1 -s 10.0.3.0/24 -j ACCEPT
and apply these changes:
iptables-apply
before restarting the lxc networking:
systemctl restart lxc-net.service
Create the container
Once that's in place, you can finally create the Fedora 29 container:
lxc-create -n fedora29 -t download -- -d fedora -r 29 -a amd64 --keyserver hkp://keyserver.ubuntu.com
To see a list of all distros available with the download
template:
lxc-create -n foo --template=download -- --list --no-validate
Logging in as root
Start up the container and get a login console:
lxc-start -n fedora29 -F
In another terminal, set a password for the root user:
lxc-attach -n fedora29 passwd
You can now use this password to log into the console you started earlier.
Logging in as an unprivileged user via ssh
As root, install a few packages:
dnf install openssh-server vim sudo man
and then create an unprivileged user with sudo access:
adduser francois -G wheel
passwd francois
I set this in /etc/ssh/sshd_config
:
GSSAPIAuthentication no
to prevent slow ssh logins.
Now login as that user from the console and add an ssh public key:
mkdir .ssh
chmod 700 .ssh
echo "<your public key>" > .ssh/authorized_keys
chmod 644 .ssh/authorized_keys
You can now login via ssh. The IP address to use can be seen in the output of:
lxc-ls --fancy
Enabling all necessary locales
To ensure that you have all available locales and don't see ugly perl warnings such as:
perl: warning: Setting locale failed.
perl: warning: Falling back to the standard locale ("C").
install the appropriate language packs:
dnf install langpacks-en.noarch
dnf reinstall dnf