Flatpak packages runs in sandbox mode: so, by design, flatpak takes a considerable amount of disk space for an individual application, even if it is a smaller one, because it pulls all dependencies for an app and runs independently. The advantage of this design is that you don't need to worry about dependencies and updates of the system that may break your app. However, it takes up huge amount of disk space.
As a consequence, the only thing that a user can do is to monitor flatpak size and perform a periodic clean. Personally, I have a script called "spring-cleaning" that I use periodically to perform a cleaning of the system (and within it there is a section related to flatpak).
Generic cleanup
- Flatpak apps may share some runtime packages, that represent the basic dependencies for apps: if a runtime is installed in your system but is not used by any flatpak app (
flatpak list --app --columns=application,runtime
lists which app use which runtime), you can remove it with flatpak uninstall --unused
. This is a cleanup that may have a great effect the first time you run it, but as you can imagine the cleanup may not be significative after the first use.
- Flatpak apps may create objects in the
/var/lib/flatpak/repo/objects
folder, that may reach a significative size. To prune these objects (that don't have an explicit reference to their app), you need to run (with sudo
, because you are cleaning objects in a system folder) sudo flatpak repair
. The impact of this cleanup may be significative every time you run the command.
- Flatpak cache files may be removed as well, in both system and user folders. You can run
sudo rm -rfv /var/tmp/flatpak-cache-*
and rm -rfv ~/.cache/flatpak/*
Specific cleanup
- You can uninstall the app that you don't need, or replace the huge ones with the .deb version of the app, if feasible. You can sort flatpak apps by size
flatpak --columns=name,size --user list
and then uninstall an app using its name flatpak uninstall <flatpak_app_name>
Combining in a script (to run with sudo)
#!/bin/bash
# Error status variables
STATUS_OK=0
STATUS_ERROR=1
# Definitions
USER_NAME="${SUDO_USER:-${USER}}"
USER_DIR="/home/${USER_NAME}"
# Execute it as root user
if [ "${USER}" != root ]; then
echo "ERROR: must be root! Exiting..."
exit "${STATUS_ERROR}"
fi
# Current status
USED_BEFORE="$(df -k / | awk 'NR>1 {print $3}')"
# flatpak cleanup
if [ -n "$(command -v flatpak)" ]; then
flatpak repair &> /dev/null
# Remove flatpak cache
rm -rf /var/tmp/flatpak-cache-*
sudo -u "${USER_NAME}" rm -rf "${USER_DIR}"/.cache/flatpak/*
# Remove unused flatpak runtimes
if [ -n "$(flatpak list --runtime)" ]; then
flatpak uninstall --unused
fi
fi
# Current status
USED_AFTER="$(df -k / | awk 'NR>1 {print $3}')"
# Summary
echo "Freed up space: $(( (USED_BEFORE - USED_AFTER)/1024 )) MB"
exit "${STATUS_OK}"
--user
? Provide the output offlatpak list --show-details --app --runtime
to list install details (all columns) of all apps and runtimes. Runsudo flatpak uninstall --unused
(--user
to just user-wide) to uninstall unused references (du -sh ~/.local/share/flatpak/repo
to test before/after).repair --user
prune objects. BTW, you can always clean cache (sudo rm -rfv /var/tmp/flatpak-cache-* ~/.cache/flatpak/**
)org.gnome.Platform
versions taking up a~1GB each but hardly any actual apps that might need those.flatpak list --app --columns=application,runtime
to list which app use which runtime, or--app-runtime=
to list apps using a specific runtime.flatpak uninstall –unused
should remove (both system and user) unused runtimes. You have flatpak older than 1.9.1?