USB Drives#

One can distribute flatpaks along with their dependencies on USB drives (or network shares, etc.) which is especially helpful in situations where Internet access is limited or non-existent.

For offline distribution to work there are a few prerequisites:

  • the remote repositories providing the app or any of its dependencies must utilize GPG signatures

  • the remote repos must all have a collection ID set on the server side

  • the locally configured remotes must have a collection ID set (on the client side)

  • the relevant remotes must be configured on the receiving computer (the one installing from the drive)

Apps can then be copied to USB drives using the flatpak create-usb command. You can refer to this blog post for an introduction.

For example, if you want to put Gedit on a USB drive:

  1. First identify the Application ID using flatpak list --app. In the case of Gedit it is org.gnome.gedit. Use flatpak info -o org.gnome.gedit to determine the origin remote. For example that may be flathub.

  2. Ensure the origin remote has a collection ID set by using flatpak remotes -d and checking the “Collection ID” column. If not, configure one with e.g. flatpak remote-modify --collection-id=org.flathub.Stable flathub. If any dependencies come from other remotes, those will also need a collection ID configured.

  3. Next, use the df command to identify the mount point for the USB drive. It may be something like /media/user/FLATPAKS.

  4. Now copy the flatpak and its dependencies to the drive:

    $ flatpak create-usb /media/user/FLATPAKS org.gnome.gedit
    
  5. Wait for the copying process to complete, at which point you should get a command prompt ($). This process can take tens of minutes especially if the USB drive and USB port aren’t USB 3.0+. Then unmount the drive before removing it:

    $ umount /media/user/FLATPAKS
    

The process for installing from such a USB drive (for example on an offline machine) differs between Flatpak versions before 1.8.0 and those after. With earlier versions you can simply use the flatpak install command as you normally would online:

$ flatpak install flathub org.gnome.gedit

For versions after 1.8.0, if your linux distribution has packaged the relevant systemd units, using flatpak install with no extra arguments still works. Otherwise, you can use the --sideload-repo option in your command invocation:

$ flatpak install --sideload-repo=/media/user/FLATPAKS/.ostree/repo flathub org.gnome.gedit

The flatpak update command also accepts a --sideload-repo option.

Alternatively, it’s possible to specify sideload sources using symbolic links placed in system-wide or user-specific directories and such sources will then be used for all Flatpak operations without the need for a --sideload-repo option. See the flatpak man page.