How to fix E: You don't have enough free space in /var/cache/apt/archives/ in APT
This error occurs when the APT package manager runs out of disk space while downloading packages. Clear the cache and reclaim storage from unused dependencies and applications.
Quick fix
Fixes E: You don't have enough free space in /var/cache/apt/archives/
sudo apt-get clean
sudo apt-get autoclean- Clean up the APT cache
- Remove unused dependencies
- Check disk usage and identify space hogs
- Remove large unnecessary applications
sudo apt-get cleansudo apt-get autocleanE: You don't have enough free space in /var/cache/apt/archives/
What this error means
APT (Advanced Package Tool) caches downloaded package files in /var/cache/apt/archives/ to avoid re-downloading them during future installations. When this directory or the root partition runs out of space, APT cannot proceed with updates or installations. This typically happens on systems with limited storage, such as Raspberry Pi devices, containerized environments, or machines with multiple large applications installed.
Typical symptoms
- apt install or apt upgrade fails with E: You don't have enough free space
- System updates cannot complete
- Installation of new packages fails mid-process
- Error occurs even when running a single package installation
Common causes
- The /var/cache/apt/archives directory contains cached .deb files from previous installations that have accumulated over time
- The root partition is full or nearly full from other applications and system files
- Large applications like Docker, virtual machines, or databases are consuming significant disk space
- System log files in /var/log have grown very large without rotation
- Orphaned dependencies and unused packages remain installed on the system
How to fix "E: You don't have enough free space in /var/cache/apt/archives/"
Run these commands to remove cached package files:
sudo apt-get clean
sudo apt-get autoclean- apt-get clean: Removes all cached .deb files from /var/cache/apt/archives/
- apt-get autoclean: Removes only obsolete cached files that can no longer be downloaded from repositories
This typically frees up several hundred MB to a few GB of space.
Run this command to remove packages that were automatically installed as dependencies but are no longer needed:
sudo apt-get autoremoveYou may also want to remove unnecessary packages you've manually installed:
sudo apt-get remove PACKAGENAMEReplace PACKAGENAME with any unnecessary packages. You can list installed packages with apt list --installed.
Verify how much space you've freed and identify what else is consuming disk space:
df -h /
sudo du -h --max-depth=1 /var | sort -h | tail -n 10The first command shows overall root partition usage. The second shows what's consuming the most space in /var. Common culprits include:
- /var/log: System logs (check with ls -lahS /var/log)
- /var/lib: Databases, Docker images, package managers
- /var/cache: Other cached application data
You can safely delete old log files if needed:
sudo rm /var/log/auth.log.1 /var/log/syslog.1If after cleaning the cache you still lack space, identify and remove large applications you don't need:
sudo apt-get remove APPLICATIONNAME
sudo apt-get autoremoveCommon space-consuming applications:
- Docker/Podman: Often stores gigabytes of images
- LibreOffice: Large office suite
- Unnecessary language packs or fonts
Check what's actually using space:
du -h --max-depth=1 /var/lib | sort -h | tail -n 5Once you've freed sufficient space, retry your original command:
sudo apt-get install PACKAGENAME
# or
sudo apt-get upgradeYou should now have enough space to download and cache the necessary package files.
Advanced notes
On Raspberry Pi devices with limited storage, you may need to expand the root filesystem using sudo raspi-config and selecting the expand root filesystem option. For systems using LVM (Logical Volume Manager), you can dynamically allocate more space to /var without reinstalling: run sudo pvresize /dev/sdXN followed by sudo lvextend -l +100%FREE /dev/vg0/root and sudo resize2fs /dev/vg0/root. On systems running in Docker or VirtualBox, consider increasing the virtual disk size in the VM settings before expanding partitions. The journal log file (journalctl) can be trimmed with sudo journalctl --vacuum-size=64M to reclaim additional space without affecting active services. For production systems, consider implementing logrotate to automatically compress and remove old logs: check /etc/logrotate.d/ for existing policies.
Frequently asked questions
- What does "E: You don't have enough free space in /var/cache/apt/archives/" mean?
- APT (Advanced Package Tool) caches downloaded package files in /var/cache/apt/archives/ to avoid re-downloading them during future installations. When this directory or the root partition runs out of space, APT cannot proceed with updates or installations. This typically happens on systems with limited storage, such as Raspberry Pi devices, containerized environments, or machines with multiple large applications installed.
- How do I fix "E: You don't have enough free space in /var/cache/apt/archives/"?
- This error occurs when the APT package manager runs out of disk space while downloading packages. Clear the cache and reclaim storage from unused dependencies and applications.
- What causes "E: You don't have enough free space in /var/cache/apt/archives/"?
- The /var/cache/apt/archives directory contains cached .deb files from previous installations that have accumulated over time The root partition is full or nearly full from other applications and system files Large applications like Docker, virtual machines, or databases are consuming significant disk space
- Is the "E: You don't have enough free space in /var/cache/apt/archives/" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐APT Official Documentation
- ๐nixCraft - Clear the Package Cache(Official Docs)
- ๐
- ๐
- ๐nixCraft - Can I Delete /var/cache/apt/archives(Official Docs)