Skip to content

Instantly share code, notes, and snippets.

@crashangelbr
Created April 14, 2021 23:01
Show Gist options
  • Save crashangelbr/bd68318a40c5c0844b66e205e75b4ea9 to your computer and use it in GitHub Desktop.
Save crashangelbr/bd68318a40c5c0844b66e205e75b4ea9 to your computer and use it in GitHub Desktop.
# Install the secure-delete package (sfill command).
# To see progress type in new terminal:
# watch -n 1 df -hm
# Assuming that there is one partition (/dev/sda1). sfill writes to /.
# The second pass writes in current directory and synchronizes data.
# If you have a swap partition then disable it by editing /etc/fstab
# and use "sswap" or similar to wipe it out.
# Some filesystems such as ext4 reserve 5% of disk space
# for special use, for example for the /home directory.
# In such case sfill won't wipe out that free space. You
# can remove that reserved space with the tune2fs command.
# See http://superuser.com/a/150757
# and https://www.google.com/search?q=reserved+space+ext4+sfill
sudo tune2fs -m 0 /dev/sda1
sudo tune2fs -l /dev/sda1 | grep 'Reserved block count'
sudo sfill -vfllz /
# sfill with the -f (fast) option won't synchronize the data to
# make sure that all was actually written. Without the fast option
# it is way too slow, so doing another pass in some other way with
# synchronization. Unfortunately this does not seem to be perfect,
# as I've watched free space by running the "watch -n 1 df -hm"
# command and I could see that there was still some available space
# left (tested on a SSD drive).
dd if=/dev/zero of=zero.small.file bs=1024 count=102400
dd if=/dev/zero of=zero.file bs=1024
sync ; sleep 60 ; sync
rm zero.small.file
rm zero.file
sudo tune2fs -m 5 /dev/sda1
sudo tune2fs -l /dev/sda1 | grep 'Reserved block count'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment