How to Remove Old Snap Package Versions in Ubuntu to Free Up Root Disk Space

Ubuntu desktop and server installations rely heavily on the Snap package management system to distribute popular software like Chromium, Firefox, Spotify, and Nextcloud in self-contained sandboxes. To safeguard users against broken software updates, Canonical’s Snap daemon (snapd) automatically retains older revisions of every installed application whenever an update is applied.

While this revision backup system allows users to roll back an app if a bug is introduced, snapd keeps these old package revisions indefinitely on the primary system root partition (/var/lib/snapd/snaps/). On workstations and laptops with modest 128GB or 256GB SSDs, these disabled historical revisions frequently accumulate between 10GB and 20GB of wasted storage space. This guide explains how to identify disabled Snap revisions and remove them safely to recover root disk space.

Checking How Much Space Snaps Are Consuming

To see how much disk space Snap packages occupy on your Ubuntu system, open the Terminal and run:

du -sh /var/lib/snapd/snaps

On systems running Ubuntu for over a year, this directory often consumes 15GB to 30GB of storage. To see the specific disabled revisions lingering on your drive, execute:

snap list --all

Look at the Notes column in the output. Any row marked as disabled represents an older, inactive software version that is no longer used by the operating system.

Step-by-Step: Removing All Disabled Snap Revisions

Rather than manually typing sudo snap remove <package> --revision=<number> for fifty individual packages, you can automate the cleanup cleanly using a simple shell loop.

  1. Open Terminal on your Ubuntu desktop.
  2. Create a small cleanup script using the built-in nano text editor:
    nano clean_snaps.sh
  3. Paste the following standard cleanup routine into the editor:
    #!/bin/bash
    # Removes disabled snap package revisions
    set -eu
    snap list --all | awk '/disabled/{print $1, $3}' |
        while read snapname revision; do
            snap remove "$snapname" --revision="$revision"
        done
  4. Save the file by pressing Ctrl + O, then press Enter. Exit nano with Ctrl + X.
  5. Make the script executable:
    chmod +x clean_snaps.sh
  6. Execute the script with administrative privileges:
    sudo ./clean_snaps.sh

Terminal will display confirmation messages as each obsolete package archive is cleanly purged from /var/lib/snapd/snaps/.

Configuring Ubuntu to Keep Fewer Snap Revisions in the Future

To prevent old Snap packages from silently accumulating and filling your hard drive again in the future, instruct snapd to retain only 2 revisions (the current active version plus one fallback backup) instead of the default 3:

sudo snap set system refresh.retain=2

Storage Reclamation Overview

Cleanup Action Commands Executed Typical Space Recovered
Purge Inactive Snap Revisions clean_snaps.sh script 5 GB – 15 GB
Set Retention Limit to 2 snap set system refresh.retain=2 Prevents 30% future bloat
Clear APT Package Cache sudo apt clean 1 GB – 3 GB

Troubleshooting Notes

  • Active Apps Are Completely Safe: The cleanup script specifically filters for packages marked with the disabled flag. Your currently running applications, user data, and personal documents remain completely untouched.
  • Cannot Set Retain Below 2: Canonical enforces a minimum retention limit of 2 to guarantee that users always have a safe rollback option if a software update introduces an unexpected crash.

Get the best tech tips delivered straight to your inbox.

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