1

I am having the famous warning "low disk space" on my Linux Mint in var/cache/apt/archive directory, and I want a permanent solution ( aka not apt-get autoclean because the mentioned directory is not enough for all the packages so cleaning it doesn't solve the problementer image description here)

What are the possible solutions to this problem?

Also is there a way to solve the problem without using partitioning or copying data to live disks like making a directory in another partition where apt can use it in the future installs?

enter image description here

  • I tried to create another directory that has enough space needed and used the command ln var/cache/apt/archive /home/new/directory but didn't work
3
  • 1
    Please edit your question and give us some more details. What exact error messages are you seeing? When do you see them? What is ../apt/archive? Do you mean /var/cache/apt/archives/? What's wrong with apt-get autoclean? "making a directory in a larger partition": larger than what? What is your current setup? Please edit your question and add more details, including the output of df -h so we can understand how much space you have to play with.
    – terdon
    Apr 12 '21 at 11:27
  • You can always format and mount another partition on /var/cache/apt/archives. or symlink it to a directory on a partition with more free space. on my machines running zfs, i created dedicated datasets for .../apt/archives, with a recordsize of 1M instead of the default 128K.
    – cas
    Apr 12 '21 at 15:18
  • @cas How to make apt use another directory to store the packages Apr 13 '21 at 13:38
0

The easiest way is to move the directory to another partition and then create a symlink from the old location to the new.

You seem to have lots of space free on /home, so use that:

  1. apt-get clean

    This step is optional, but highly recommended. It will delete all of the downloaded .deb files currently in /var/cache/apt/archives. If you don't want to delete them, that's fine but the third step (mv) will take a while - however long it takes to copy and delete the archives from one partition to another.

  2. Make a convenient directory for the .deb archives:

    mkdir -p /home/var/cache/apt/

    You can put it anywhere you like under /home (or any other partition with lots of free space available) e.g. /home/apt will do, but it's useful and convenient to keep the same directory structure.

  3. mv /var/cache/apt/archives /home/var/cache/apt

  4. ln -s /home/var/cache/apt/archives/ /var/cache/apt/

  5. That's it, done.

    The next time you use apt, apt-get, etc it will follow the symlink from /var/cache/apt/archives to /home/var/cache/apt/archives - all of the downloaded files will be stored there.

BTW, if you're still short of space on /, you might want to do the same thing with /usr/share/doc - mv and symlink it to, e.g., /home/usr/share/doc.

4
  • thank you so much,appreciated... I already did those steps before and it turned up that the shortage of storage was because snapshots of the system taken daily, since I was installing packages at the same time so I thought the symlink not working due to increasing of storage used! sorry for any inconvenience. Apr 14 '21 at 12:28
  • yeah, deleting files from a fs with snapshots won't actually release the space while there are still snapshots containing those files. Which means you should exclude .../cache/apt/archives from automatics snapshots (this is what i've done with my apt/archives zfs datasets on my systems). There really isn't any good reason to snapshot them, they can always be re-downloaded from the net.
    – cas
    Apr 14 '21 at 12:38
  • The snapshots weren't for the archives, it was for the whole system, anyways thankfully the problem is solved Apr 15 '21 at 12:51
  • I guess you're using btrfs? in that case, make the apt archives directory be a separate sub-volume and exclude it from your auto snapshot script. and exclude it from backups too, both are a waste of time and disk space for the apt archives.
    – cas
    Apr 15 '21 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.