Understanding Why /var/lib/snapd Consumes So Much Space
When a Linux system reports that the root filesystem is completely full, the cause often lies somewhere inside the /var directory. One of the most common and least obvious contributors is Snapd, the package and application management system used in Ubuntu and other distributions.
Snap stores application revisions, snapshots, cached packages, and metadata. Over time, these layers accumulate silently, and it’s not unusual for /var/lib/snapd to grow beyond 10 GB. This can cause package managers to fail, logs to stop writing, and system services to behave unpredictably.
This article walks through the process of diagnosing the issue and cleaning up Snap safely and effectively.
1. Diagnose What’s Filling the Root Filesystem
Start by checking disk usage across the /var directory:
sudo du -sh /var/* | sort -h
If /var/lib is significantly larger than expected, inspect it more closely:
sudo du -sh /var/lib/* | sort -h
A large /var/lib/snapd directory typically indicates the presence of:
- obsolete application revisions
- cached downloads
- signature assertions
- automatic snapshots
- leftover
.snappackage images
2. Remove Old Snap Revisions
Snap retains older versions of applications even after updates. To list all installed snaps, including inactive revisions:
snap list --all
Rows marked as “disabled” represent inactive revisions that can be safely removed:
sudo snap remove <name> --revision=<rev>
Removing inactive revisions often frees several gigabytes.
3. Delete Snap Automatic Snapshots
Before removing or updating snaps, the system may create automatic snapshots. These snapshots persist until explicitly deleted.
List snapshots:
sudo snap saved
Delete snapshots you no longer need:
sudo snap forget <id>
This is one of the quickest ways to reclaim disk space.
4. Clean Up Leftover .snap Package Files
Downloaded .snap package files live under:
ls -lh /var/lib/snapd/snaps/
If snaps have been removed but their package files remain, they can be deleted:
sudo rm /var/lib/snapd/snaps/<file>.snap
Only remove files corresponding to snaps that are no longer installed.
5. Clear Snap Assertions and Cache
Snap maintains:
- metadata assertions
- cached packages
These can grow large over time. Clear them safely:
sudo rm -rf /var/lib/snapd/assertions
sudo rm -rf /var/lib/snapd/cache/*
Snap will regenerate required metadata automatically.
6. Handle Deleted Files Still Held by Running Processes
Sometimes deleted files remain open by running processes, preventing the disk space from returning.
Identify these ghost files:
sudo lsof / | grep deleted
Restart the listed processes or reboot the machine to release the space.
7. Repair Package Management After Clearing Space
A full root partition may interrupt package operations. If dpkg is stuck, repair it:
sudo dpkg --configure -a
Then clean unused packages:
sudo apt autoremove --purge
sudo apt clean
8. (Optional) Remove Snapd Entirely
If you no longer rely on Snap-based applications, you can remove Snapd from the system:
sudo apt purge snapd
sudo rm -rf /var/lib/snapd
sudo rm -rf ~/snap
This prevents Snap from consuming additional space in the future.
Conclusion
Snap simplifies software installation, but it can silently consume large amounts of disk space over time. By cleaning old revisions, removing automatic snapshots, deleting unused .snap files, and clearing cached metadata, you can significantly reduce the size of /var/lib/snapd and restore free space to your root filesystem.
Regular maintenance is recommended, especially on systems with smaller root partitions, developer environments, or machines with frequent Snap activity.

Leave a Reply