Root partition full with flatpak cache

I have 52GB for / partition and suddenly system informed that it is full. Examination with Disk Usage Analyzer tool revealed there is 18GB cache in /var/tmp/ that belongs to Flatpak.

used command:
flatpak uninstall --unused
but 18GB cache is there again
also
used command:
sudo flatpak repair

nothing changed again.
Any other options?

I usually do
$ sudo rm -rfv /var/tmp/flatpak-cache-*
which solves the problem.

1 Like

The flatpak caches in /var/tmp are temporary files used only during installation (see man flatpak).

There shouldn’t be anything substantial left there, but if there is, it’s safe to delete (assuming there are no ongoing flatpak transactions).

3 Likes

Thanks! yes, this solves the problem. I think that flatpak should fix such issues, this is an application design flaw.

1 Like

I am not sure this is a application design flaw that can be fixed.
Fedora now uses /tmp as a virtual file system in RAM, but /var/tmp is a physical file system. Some installations seem to actually use /var/tmp as /tmp with a symlink.

I seem to recall that there have been issues with cleaning out /tmp, historically and ongoing, and with having it as a physical file system there seem to always be problems with cleaning it out. (I think this may have been a factor in fedora switching to the virtual file system approach.) It seems the system is supposed to keep /tmp (& /var/tmp) at a reasonable usage when the apps fail to do so.

I agree that it should not continuously fill up but since I do not do development cannot speak to how it could be cleaned out regularly. What about servers that may run for months without ever rebooting? How does /tmp (or /var/tmp) get cleaned out for them?

1 Like

See man tmpfiles.d. On Fedora, /usr/lib/tmpfiles.d/tmp.conf sets the age of /tmp to 10 days and /var/tmp 30 days, meaning any files older than that are deleted when systemd-tmpfiles-clean.timer runs.

3 Likes

Did any flatpak operations fail before this (possibly due to insufficient space in the first place)? Or maybe a crash while installing something?

did not noticed anything like that

Hi. I’m having same issue flatpak consuming disk space in /var/tmp. Are there any fixes to prevent that happening again and again ? I know I can get rid of cache files by using ‘rm’, but is there a permanent solution ?

You can set up a scheduled cleanup task:
Systemd Timers for Scheduling Tasks - Fedora Magazine

I think this should be done by default like what we see in android it is a flaw in flatpak design in my opinion.

2 Likes

flatpak is designed to not keep these temporary caches. On my system, /var/tmp/flatpak-* takes up almost no space immediately after a flatpak transaction. If you monitor the filesystem during a transaction, you can see the temporary repo get created and disappear after it’s copied to the actual install location.

These users may be encountering a bug in flatpak, but without any reproducible steps it’s hard to diagnose.

Also as previously mentioned, /var/tmp is already cleaned regularly, unrelated to flatpak.

1 Like