Main Content

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 .

$ 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 .

$ sudo pv /dev/zero > /mnt/usb/

Sample output .

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

Remove the resulting file .

$ rm