71

When I run the command to install the package solr-jetty, I am told

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

Here's the result of the df -H command:

enter image description here

I have installed Ubuntu with VirtualBox on my Mac.

How can I fix this problem?

Zanna
  • 70,465
epsilones
  • 1,471
  • In my case, this problem went away by just rebooting the system. I guess my computer has commutated very much temporary files. – thepunitsingh Dec 18 '20 at 10:20

7 Answers7

80
sudo apt-get autoclean

This will delete all packages not currently installed. If that doesn't free up enough space, then use sudo apt-get clean. This clears out all .debs downloaded and/or installed.

But it looks like your hard disk is out of space. Seriously out of space. 61Mb is not enough for a good working system. I found 2 alternatives that can circumvent space-related problems though both might be hard to pull off when using a virtual machine. A more permanent solution would be to increase the size of your virtual machine (and I would also advise using the method that allows the machine to dynamically increase in size; VirtualBox has such a setting).


Alternative if you have a partition or external storage.

With this method you re-route the location where .debs are stored:

sudo mv -i /var/cache/apt /media/{dir_of_mounted_disc}
sudo ln -s /media/{dir_of_mounted_disc}/apt /var/cache/apt

Run the upgrade and install. After you are done you can switch back to normal with:

sudo apt-get clean
sudo unlink /var/cache/apt
sudo mv /media/{dir_of_mounted_disc}/apt /var/cache

Of course {dir_of_mounted_disc} needs to be changed to the name of your mounted disc.

Another alternative

This way you create a RAM disc:

sudo mkdir /media/{directory}
sudo mount -t tmpfs tmpfs /media/{directory}
sudo ln -s /media/{directory}/apt /var/cache/apt

Clean up as with the 1st alternative.

Warning this requires a large amount of RAM so may not be useable when using a virtual system.

sugab
  • 4,367
Rinzwind
  • 299,756
  • 2
    I tried the two commands and I have the same 'not enough space' message – epsilones Aug 22 '12 at 09:35
  • So I edited my question put the visual result of the command (soory I put some image because I don't know how to copy paste the content of the shell...) – epsilones Aug 22 '12 at 09:41
  • By the way, I tried with what I got by doing ls in the media directory, I found 'cdrom'. So I ran the sudo mw command and I got an error message : could not create directory /media/cdrom/apt : 'read only filme system'... – epsilones Aug 22 '12 at 09:53
  • Do you mean the last command you suggested are useless if I don't have a USB stick or an external HDD ? – epsilones Aug 22 '12 at 10:05
  • @newben no problem :) if you do not mind please remove all the comments (except the 1st one :D ) since we are turning this in a chat :+ – Rinzwind Aug 22 '12 at 10:16
  • if you are creating a docker image, your linux host must have free disk space. When images creation fail, we get failed images consuming disk space in host. List the failed images with docker images and choose which one to remove with docker rmi <image id> – Junior Mayhé Jul 30 '22 at 11:40
9

Whenever you install a program, the packages (.deb files) get stored in /var/cache/apt/archives, which obviously take up space (a lot of space if there are many packages installed).

To get rid of them, use:

sudo apt-get clean

Incase you're wondering what is the difference between clean and autoclean, here is what the man page says:

clean: clean clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. APT is used as a dselect(1) method, clean is run Those who do not use dselect will likely want to run apt-get clean time to time to free up disk space.

autoclean: Like clean, autoclean clears out the local repository of package files. The difference is that it only removes package files can no longer be downloaded, and are largely useless. This a cache to be maintained over a long period without it out of control. The configuration option Clean-Installed will prevent installed packages from erased if it is set to off.

green
  • 14,306
9

These commands will remove extra packages that are no longer required .

Open terminal (Ctrl-Alt-T) and type

sudo apt-get autoclean
sudo apt-get autoremove 
stephenmyall
  • 9,855
Raja G
  • 102,391
  • 106
  • 255
  • 328
3

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
3

I hit this error and fixed this by removing none docker. you can remove none docker by one of these lines:

docker rmi $(docker images -f "dangling=true" -q) -f
docker rm $(docker ps -a -q)
docker image rm $(docker image ls -f 'dangling=true' -q)
2

The issue re: 'You don't have enough free spacve in /var/cache/apt/archives/' may be related to this bug: https://bugs.launchpad.net/ubuntu/+source/update-manager/+bug/1054903 Particularly if /var/cache/apt is on a tmpfs which gets erased every boot. Is it possible that you've sym-linked /var/cache/ to /tmp/cache/ or something similar in order to save space?

If this is the case the instructions to solve/work-arround it are on the bug report above.

  • 1
    Can you add a summary of the suggested workaround, quote parts that need quoting, and add relevant steps to take from the link. – Mateo Oct 05 '12 at 01:05
1

This is more of a workaround/helpful tip.

This was happening on my virtual machine because I had allocated too much space to swap (close to 40%). I quickly resized it using gparted and was able to reclaim some more space for the root partition.

Now I can update the long neglected VM which required about 3GB of updates.

smac89
  • 854