Skip to content

Freeing Up Space After Deleting Data on a ZFS Server

On our servers, we use the ZFS file system, which operates on the Copy-on-Write principle, enabling us to back up data using snapshots.

The Copy-on-Write principle means that when a file or data is changed, the old data on the disk is not immediately overwritten. Instead, a new version is created in a different location, and the original data remains unchanged as long as there is a reference to it, such as from a snapshot.

Snapshots preserve the system state at the moment they are created. Therefore, deleted files are still “held” in the snapshot until the old snapshot is removed.

The following graphs illustrate the process:

  • State After Deleting Data:

The "Used Space" value has decreased, but the "Free Space" has not increased. Additionally, the total disk size ("Total Size") appears to have decreased because space is still occupied by snapshots. The data is no longer present in /var/www but still exists within the snapshots on the server.

Only after removing the corresponding snapshots does the disk space actually get freed, which is reflected in the graphs.

  • State After Deleting Snapshots:

The "Used Space" remains unchanged, but the total disk size ("Total Size") returns to its original value (accounting for the deleted snapshots), and the "Free Space" increases. Space from the deleted files is truly freed only at this point.

In critical situations where space needs to be freed urgently, we can accelerate this process.