Skip to content

Methods to save space on your '/root' partition while using flatpak  #2337

@aiamuzz

Description

@aiamuzz

Information

Flatpak installs at the default location /var/lib/flatpak. So all applications get installed inside this flatpak folder(runtimes/platform/applications ... everything in this folder) eating away at the /root partition.

Method 1 : uses a simple hack making use of linux feature of symbolic links.
Method 2 : uses the official flatpak feature to install applications at custom locations/paths.

Method 1 : Unofficial 'HACK' method (this method makes sense ONLY if you have a separate partition for /home ... if /root & /home are on the same partition its useless to try this method)

Lets say your home is located at /home/user ... ('user' could be the name of your user and the same needs to be replaced with the actual user name on your system in place of user wherever found in the below commands)

sudo mv /var/lib/flatpak /home/user
cd /var/lib
sudo ln -s /home/user/flatpak flatpak

that's it !!! ... .... with the symbolic link at /var/lib ... all your flatpak applications will get routed and installed in your /home partition keeping the /root partition free.

Method 2 : Official feature of installing it in a custom location of your choice by creating extra.conf file

Its best(not mandatory) if the following conditions are adhered to ...

  • Its is best to have a separate partition on your internal hard disk(preferable) dedicated to installing flatpak applications.
  • It is best to configure you linux OS to auto mount partition on boot ...
  • Its is best to let the partitions mount at their default locations ... some OSes mount it in /media/user and some mount it in /mnt
  • It is best to name/label the partition

The following commands are written assuming the default location being /media/user and partitions get auto mounted at this location ... make changes according to your own systems. ... i have a separate partition labeled it as Flatpak(name of the partition not the folder).

sudo mkdir /media/muz/Flatpak/flatpak
sudo mkdir /etc/flatpak
sudo mkdir /etc/flatpak/installations.d

sudo gedit /etc/flatpak/installations.d/extra.conf

Lets name this custom install location ...
Lets say i name it myFlatpaks ... you can use your own names instead, just make sure the name 'myFlatpaks' with your name in the commands/entries below.

Paste the following block in the extra.conf file and save it ...

[Installation "myFlatpaks"]
Path=/media/muz/Flatpak/flatpak/
DisplayName=myFlatpaks Installation
StorageType=harddisk

Now lets add the flathub remote to this custom install location ...

flatpak --installation=myFlatpaks remote-add flathub https://flathub.org/repo/flathub.flatpakrepo

Thats It !!!

Advantages of using a Separate partition dedicated ONLY for flatpak applications.

  • In cases where the OS is reinstalled from scratch which involves formatting /root and /home partition. (Tested and Works)
  • In cases where you are switching from one linux distro to another.(not yet tested as such a situation hasn't been encountered by me).

I like to call this setup of using a dedicated partition as 'INSTALL ONLY ONCE' setup !!!

Commands to manage applications at this newly created custom install location.

Install
flatpak --installation=myFlatpaks install flathub org.application.name

Uninstall
flatpak --installation=myFlatpaks uninstall flathub org.application.name

List
flatpak list - to list all applications
flatpak --installation=myFlatpaks list - to list applications only from a specific installation location.

Run
flatpak run flathub org.application.name

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions