How to fix "E: You don't have enough free space in /var/cache/apt/archives/."

62,467

Solution 1

If you're getting this error in a Docker container - it helped me to do a

docker system prune

Solution 2

Fixing this largely depends on where the cruft has built up.

  1. Start with unnecessary packages and apt cache:
sudo apt autoremove && sudo apt autoclean
df -h
  1. Use du to look for cruft in /var and /var/log.
sudo du -xh --max-depth=1 /var
sudo du -xh --max-depth=1 /var/log

If a lot of space is consumed by /var/log, I usually cleanup old log files with:

# Note, change +30 to the number of days you want to keep.
sudo find /var/log -mtime +30 -type f -delete

Other directories probably need to be handled differently.

  1. Lastly, check if running processes have a lock on files pending deletion.
sudo lsof -nP | grep '(deleted)'
# If your system doesn't have lsof installed:
sudo apt install lsof 

If there are large files pending deletion, you may need to restart the process or daemon with the lock.

Solution 3

Wouldn't apt-get clean free enough space, there is a faster way, than resizing filesystems:

mv /var/cache/apt/ /home/
ln -s /home/apt/ /var/cache/apt

Make sure you there is no /home/apt directory beforehand.

Solution 4

I think var/cache/apt/archives is a bit full soo

apt-get clean packages

Solution 5

In my case, I was getting this error

E: You don't have enough free space in /var/cache/apt/archives/.

while installing a package inside Debian container.The problem got resolved by going to Docker :

dashboard -> Settings -> Resources 

and increasing the Disc image size from 60G to 80G

Share:
62,467

Related videos on Youtube

Navdeep Gupta
Author by

Navdeep Gupta

Updated on September 18, 2022

Comments

  • Navdeep Gupta
    Navdeep Gupta over 1 year
    E: You don't have enough free space in /var/cache/apt/archives/.
    root@kali:~# df -H
    Filesystem      Size  Used Avail Use% Mounted on
    udev            2.0G     0  2.0G   0% /dev
    tmpfs           406M  7.0M  399M   2% /run
    /dev/sda6        12G   11G  480M  96% /
    tmpfs           2.1G   78M  2.0G   4% /dev/shm
    tmpfs           5.3M     0  5.3M   0% /run/lock
    tmpfs           2.1G     0  2.1G   0% /sys/fs/cgroup
    /dev/sda8        58G  114M   55G   1% /home
    tmpfs           406M   37k  406M   1% /run/user/0
    
    • Freddy
      Freddy about 4 years
      I don't know what /dev/sda7 is, but you have lots of free space in /dev/sda8. Maybe resize your /home and move the freed space to /?
  • we.mamat
    we.mamat about 3 years
    ran this and i got 22 Gigs back 😎
  • inostia
    inostia about 3 years
    If using minikube, do minikube ssh first to get into the VM.