zerofree command not found

In this troubleshooting guide we learn how to fix zerofree command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

zerofree: command not found

or when using sudo you get the following error message

sudo: zerofree: command not found

Solutions to zerofree: command not found

How To Fix zerofree: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu zerofree is provided by zerofree package.

zerofree is:

Zerofree finds the unallocated blocks with non-zero value content in an ext2, ext3 or ext4 file-system and fills them with zeroes (zerofree can also work with another value than zero). This is mostly useful if the device on which this file-system resides is a disk image. In this case, depending on the type of disk image, a secondary utility may be able to reduce the size of the disk image after zerofree has been run. Zerofree requires the file-system to be unmounted or mounted read-only.

The usual way to achieve the same result (zeroing the unused blocks) is to run “dd” to create a file full of zeroes that takes up the entire free space on the drive, and then delete this file. This has many disadvantages, which zerofree alleviates:

  • it is slow;
  • it makes the disk image (temporarily) grow to its maximal extent;
  • it (temporarily) uses all free space on the disk, so other concurrent write actions may fail.

Zerofree has been written to be run from GNU/Linux systems installed as guest OSes inside a virtual machine. If this is not your case, you almost certainly don’t need this package. (One other use case would be to erase sensitive data a little bit more securely than with a simple “rm”).

To fix this problem, we can install more using the command below.

sudo apt-get -y install zerofree

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install zerofree.

sudo apt -y install zerofree

Or if you have aptitude installed you can use the following command.

sudo aptitude install zerofree

Summary

In this tutorial we learn how to fix zerofree command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.