31
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
1
  • 1
    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 /?
    – Freddy
    Apr 7, 2020 at 18:09

9 Answers 9

54

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

docker system prune
3
  • 4
    ran this and i got 22 Gigs back 😎
    – we.mamat
    Feb 24, 2021 at 13:11
  • If using minikube, do minikube ssh first to get into the VM.
    – inostia
    Mar 18, 2021 at 6:15
  • Extra clarification... I received the error when issuing docker build (which is perhaps what @barfuin meant) and his/her suggested fix (docker system prune) did indeed solve the problem for me (got past previous point of failure).Thank you.
    – jamiet
    Sep 20, 2022 at 10:31
18

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.

6

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.

4

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

apt-get clean packages

2

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 a Debian container.The problem got resolved by going to Docker:

Dashboard -> Settings -> Resources 

and increasing the disc image size from 60G to 80G. This is a temp solution, you will need to clear unused images/container/volumes to reduce the disc space

1

I was getting the same problem, but in my case, this problem went away by just rebooting the system. I guess my computer has commutated very much temporary files.

If nothing works, you might give rebooting a try!

1

This seems to happen quite often when using micro SD as a hard drive for Raspberry Pi.

raspi-config --expand-rootfs

That works for Raspberry Pi OS but if you're using your Pi for Kali you need

kalipi-config --expand-rootfs

It seems every time I use a fresh installation of Kali for the Pi, it won't upgrade without using the command. Rarely though do I require using it on a fresh installation of Raspberry Pi OS.

1

When you use the Rasp Pi imager it auto partitions boot and bootxx and leaves the rest free not allocated.

The simple fix is:

  1. Open GParted

  2. Within GParted

    • Go down to the second partition
    • Click the move/resize option
    • Allocate the free space to the second disk.
    • Press the check at the top.
  3. In a terminal

    sudo apt update && sudo apt upgrade && sudo apt dist-upgrade
    
0

this error message showed up on a raspberry pi zero-w with fresh install of Raspbian 10 Buster:

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

The other answers here are valid, but this fresh image had no significant previous packages for removal, so removing them didn't help.

solution (1): use raspi-config --> Advanced --> Expand Filesystem

this will expand the root filesystem to use the entire sd card.

solution (2): or from the command line:

raspi-config --expand-rootfs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .