Freeing Up Disk Space on Ubuntu: How to Manage Snap Revisions
Understanding Snap Revisions and Their Importance
Checking Disk Usage: Identifying Space Hogs
A Step-by-Step Guide to Removing Disabled Snap Revisions
The Temporary Nature of Snap Cleanup: What to Expect
Running Out of Disk Space on Ubuntu? Check Your Snap Revisions!
If you’ve ever received those dreaded low disk space warnings on your Ubuntu system, particularly on a modest 40GB partition, you know the feeling of impending panic. The usual troubleshooting tips—like clearing caches or uninstalling applications—can feel inefficient. Recently, I stumbled upon a significant source of wasted space: old Snap revisions.
After opening the Disk Usage Analyzer and running sudo du -sh /var/lib/snapd, I discovered that nearly 8GB was consumed by outdated Snap versions. These versions, remnants of every Snap application I’ve installed, were idly taking up space “just in case” I needed to roll back—something I’ve never actually done.
Why Snap Revisions Exist (and Why You Should Keep Some)
Before we dive into the cleanup process, let’s understand why Snap revisions exist and why having a couple can be beneficial.
Many users might be tempted to use scripts available online to automatically remove all disabled Snap revisions. While this approach may seem handy, it indiscriminately removes every backup, which is risky—especially for critical applications like kernels and drivers. If you’re comfortable with the risk, feel free to go that route, but a manual approach gives you greater control over what gets removed.
Snapd retains two versions of all Snap applications. This ensures that if an update causes issues, you have a reliable backup to roll back to. The silent background updates of snaps make this functionality especially useful, particularly in industrial, IoT, and edge computing environments, where stability is crucial.
For those of us with space constraints, however, an 8GB “worst-case” backup might feel excessive.
Checking What’s Taking Up Space
To get started, you’ll want to examine what specifically is eating up your precious disk space. Use the following command in your terminal:
sudo snap list --all
This command provides a comprehensive list of all installed Snaps, including cores, runtimes, and drivers, along with their revision numbers and active/disabled statuses. Although this command doesn’t return size data, you can use another command to assess the total disk usage:
sudo du -sh /var/lib/snapd
For a more visual representation, I recommend using the Disk Usage Analyzer and navigating to /var/lib/snapd/snaps. This method will display not only the sizes but also the dates of the various Snap versions, giving you insight into how old the disabled versions are.
Removing Disabled Snap Revisions
Once you’ve identified the Snap revisions you want to delete, the next step is removal—proceed with caution! Return to your terminal and execute the following command, but replace 0000 and snap-name accordingly:
sudo snap remove --revision=0000 snap-name
Before hitting enter, double-check your revision number and Snap name. There’s no confirmation prompt, so it’s easy to make a mistake.
For clarity, I recommend using two terminal windows: keep one open with the list of Snap revisions while you perform the removal in another. This helps focus your attention and minimizes errors.
This Is Not a Permanent Fix
It’s important to note that this is not a one-time solution. As new versions of installed Snaps are updated, old revisions will start to pile up again. Periodic cleanup sessions will be necessary, especially if you commonly use Snap applications.
If space is a critical issue for you and you’re reliant on Snaps, taking this time to manage Snap revisions is well worth it. On systems with multiple Snap installations, you might be shocked to find your Snap folder consuming gigabytes of space!
Conclusion
Keeping your Ubuntu file system clean and efficient can feel like a constant battle, but managing Snap revisions is a manageable task that can free up a significant amount of space. Have you ever faced issues with disk space due to Snap revisions? What strategies do you use to tackle this problem? Let me know in the comments!