How to Stop Ubuntu from Automatically Removing Old Snap Packages

The Unwanted Housekeeping

The Snap package management system in Ubuntu is designed to keep applications updated silently in the background while ensuring system stability. To provide a safety net in case a new update breaks an application, the Snap daemon (snapd) automatically retains the previous versions of the software. However, to save disk space, the system is configured by default to automatically remove older revisions once a certain limit is reached. If you rely on specific legacy versions of software for compatibility reasons, this automatic pruning can cause significant disruption.

Configuring Retention Policies

While you cannot entirely disable the version retention system without breaking the package manager, you can configure the Snap daemon to hold onto a much larger number of previous versions, effectively stopping the aggressive auto-removal. Open a terminal window (Ctrl+Alt+T) and use the built-in configuration command to change the system-wide retention policy.

Type the following command and press Enter: sudo snap set system refresh.retain=20. You will be prompted for your administrator password. This command instructs the Snap daemon to retain up to 20 previous versions of every installed package before it begins deleting them. While this will consume significantly more disk space over time, it ensures that your critical older software versions remain available for manual rollbacks when necessary.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.