0

Today I'm trying to save some valuable space on my system disk and I might have a real newbie question: Can I safely detete the contents of /var/tmp (flatpak items)?

$ sudo du -sh /var/tmp
1.5G    /var/tmp

There are hundreds of flatpak-cache-ABCDEF (variable endings).

Specifically, now, 472 of flatpak-cache-?????? directories, as per:

$ \ls -ld /var/tmp/flatpak-cache-?????? | wc -l
472

So, I thought maybe if I restart my desktop and delete the contents right away, would there be any harm done?

3
  • I recommend deleting from a live media (or alternatively, another system) when your computer isn't running.
    – user598527
    Commented Aug 2, 2023 at 13:14
  • @user598527 And why is that? Commented Aug 2, 2023 at 13:58
  • Programs may be actively reading or writing (to) the said paths, removing when running may lead to errors (albeit I don't know how much of a concern this is).
    – user598527
    Commented Aug 3, 2023 at 8:49

3 Answers 3

1

I freed up several gigs of files under /var/tmp/flatpak-cache-ABCDEF by enabling systemd-tmpfiles to perform cleanup automatically. Distributions could include this under /usr/lib/tmpfiles.d/*.conf but mine did not, so I created a file called /etc/tmpfiles.d/flatpak.conf with the following contents:

# clean up flatpak cache folders on boot after ten days
R!  /var/tmp/flatpak-cache-*    - - -   10d

After a reboot my /var went from 2G free to 9G free. See more in the man pages:

man tmpfiles.d

See also systemd.io for more information.

0

The Flatpak Command Reference mentions this:

FLATPAK_SYSTEM_CACHE_DIR The location where temporary child repositories will be created during pulls into the system-wide installation. If this is not set, a directory in /var/tmp/ is used. This is useful because it is more likely to be on the same filesystem as the system repository (thus increasing the chances for e.g. reflink copying), and we can avoid filling the user's home directory with temporary data.

It states these data are really only temporary, so I have deleted all such items already having no issues with Flatpak'ed programs.


So, I issued this:

rm -r /var/tmp/flatpak-cache-??????

and rebooted that machine.

-1

A script that a good soul created to clear /var/tmp/flatpak-cache* at every boot ( there is also an explanation of why problems arise there ) This script has not been tested very well... But for the time being it is already there ( Oct 19, 2017 )... The script is automatic and works on startup.

https://github.com/flatpak/flatpak/issues/1119

I consider posting this information as a personal thank you for all the times Stack Overflow has helped me with my system problems. But please do get return to script author Pete "stepnjump" at the link provided. The community must help each other! Without depending on "Support" to the user from disreputable companies, which only offer "fake" support to justify the very expensive licensing they charge!

1
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review Commented Apr 16, 2023 at 8:46

You must log in to answer this question.

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