🌑

Linhost.info

Linux - Zero Out All Available Free Space

Because I tend to forget. This is a simple way to zero out all free space on a drive all that is needed is PV and administrative privileges . If PV is not installed on the system you can install it via your package manager .

1
sudo apt-get install pv

We will be directing all /dev/zero output to a file in the target drive we wish to zero-out . Once all free space is occupied in the target drive the operation will stop by itself .

1
sudo pv /dev/zero > /mnt/usb/delete.me

Sample output .

1
2
pi@raspberrypi:~ $ sudo pv /dev/zero > /mnt/usb/delete.me
202MiB 0:00:06 \[6.56MiB/s\] \[ <=>

Remove the resulting file .

1
rm delete.me

— Jan 23, 2017