How to Offline Update Fedora Workstation

Did you want to update your Fedora offline? It is possible to download the system updates on to a USB drive when having an internet connection, and then apply it offline to another Fedora system.

Are you running Fedora as your favorite Linux distribution? Do you have a slow or no internet connection? If so, read along and know how to use the Fedora Offline Package Manager. Fedora Offline Package Manager (OPM) is a solution for users who want to update their system and install new packages without the internet.

The OPM is available in two applications. The command-line version and a web application developed in Python-flask.

Offline Fedora Update

In this post, we will focus on the command-line way, which will require us to run a couple of terminal commands.

Use Cases

Let’s look at some of the situations where the Fedora Offline Package Manager would be a reliable utility for Fedora users.

  • Having a good internet connection at your college or workplace but limited internet access back at home where you have a PC running Fedora
  • Relocating to a place with unreliable or no internet connection
  • No internet access at home, but you can go to a cybercafe with good bandwidth

Fedora and other RPM-based Linux distros use the DNF package manager to install, update and remove packages. To download packages for offline use in Fedora, we use the DNF command with the “download only” parameter. Let’s see how you use Fedora Offline Package Manager.

Update all system packages

The Fedora DNF command has several functions, but one of the best is the “download” option. You can use it to download an RPM package and install it on any Fedora system without an internet connection.

To get started, we first need to get all the package names we need to download on our offline PC. You can easily do this by running the command below.

dnf repoquery --upgrade --queryformat '%{name}.%{arch}'

Update all system packages
Update all system packages

Copy all the listed packages on the Terminal and save them in a file – say “package_updates.txt.” To download the packages, run the command below.

dnf download --resolve $(cat package_updates.txt)

Download Packages
Download Packages

You can also include the “–downloaddir” argument to download RPM packages to a specific directory.

dnf download --resolve $(cat package_updates.txt) --downloaddir="/home/tuts/Desktop/programs"

Downloads Directory
Downloads Directory

Copy the downloaded packages on a USB drive to use on the offline computer. To install the packages, use the “dnf install” command.

sudo dnf install /path-to-rpm

However, there is a drawback here. You will have to execute the above command for every package. That will be tiresome when you have hundreds of packages to install. To solve this, we can automate the whole process with a simple bash script.

#! /bin/bash
for FILE in *;
do dnf install $FILE;
done

Save the file as ‘.sh’ file – say ‘installer.sh’ and put it in the directory containing your downloaded packages. Now, run the bash script with root privileges.

sudo installer.sh

Install packages
Install packages

Download single Apps

Alternatively, you can download updates for specific applications. To get started, launch the Terminal on the computer with an internet connection. You can use the keyboard combination Ctrl + Alt +T to open it. We will download Chromium and install it on our offline Fedora system. Type the command below:

sudo dnf download chromium

Download Chromium
Download Chromium

This command will download the latest release of the Chromium browser and save it in the “/var/cache/dnf” directory. You can access this directory with the change directory “cd” command, as shown below.

cd /var/cache/dnf

Once in this directory, look at the various sub-directories present and copy your files to a USB drive. If the file is not in the “/var/cache/dnf” directory, check your home folder.  Copy the file in a USB drive to install it on your offline computer using the command below.

sudo dnf install /path-to-package

Install Chromium
Install Chromium

In case you get the error “No such command” with the “dnf download” command, you will need to install “dnf-plugins-core.”

sudo dnf install dnf-plugins-core

Download Apps to a specific directory

It can be quite a hassle navigating through the “/var/cache/dnf” or home directory since there are other sub-directories present. Fortunately, we can force the DNF to download packages to a specific folder with the “–downloaddir” argument.

In the command below, we want to download the chromium package to the Programs folder on the Desktop.

sudo dnf download --downloaddir="/home/tuts/Desktop/Programs"

Downloads apps with dependencies

The above commands will download the RPM package from the Fedora repository for use in computers with limited internet access. However, if you want to download every single library and dependency required by an application, we will use the “–resolve” parameter.

For example, to download Chromium and all its dependencies, we will use the command below.

sudo dnf download chromium --resolve

Download Chromium
Download Chromium

To download to a specific directory, we will add the “–downloaddir” parameter.

sudo dnf download chromium --resolve --downloaddir="/home/tuts/Desktop/programs"

To install, run the command below.

sudo dnf install chromium

Conclusion

That’s a complete guide on how to use the Fedora Offline Package Manager (OPM). You can now install updates and applications on any offline Fedora system with much ease. Be sure to share with our readers how you go about with this powerful OPM in the comments below.

Related Articles

3 COMMENTS

  1. On the online PC as root with exact Fedora 28 remix installation as offline pc:

    dnf repoquery –upgrade –queryformat ‘%{name}.%{arch}’ > pkg-updates.txt
    dnf dowload –resolve $(cat pkg-updates.txt) –downloaddir=”/root/updates”
    dnf download –resolve $(cat pkg-updates.txt) –downloaddir=”/root/updates”
    tar -czf /shared/updates.tz updates

    On the offline PC as root with the exact Fedora 28 remix installaton:

    tar -xzf updates.tz
    cd updates
    for file in *; do dnf install $file; done

    .
    .
    .
    Repository updates has no mirror or baseurl set.
    Error: Failed to synchronize cache for repo ‘fedora’
    Repository updates has no mirror or baseurl set.
    Error: Failed to synchronize cache for repo ‘fedora’
    Repository updates has no mirror or baseurl set.
    Error: Failed to synchronize cache for repo ‘fedora’
    Repository updates has no mirror or baseurl set.
    Error: Failed to synchronize cache for repo ‘fedora’
    Repository updates has no mirror or baseurl set.
    Error: Failed to synchronize cache for repo ‘fedora’
    Repository updates has no mirror or baseurl set.
    Error: Failed to synchronize cache for repo ‘fedora’
    .
    .
    .

    Followed this guide to the letter…not sure why I am having problems. Tried “rm -rf /var/cache/dnf” and “dnf clean all” on the offline PC but it still fails.

  2. Although I still get some errors (I will debug once the script finishes) I had to add –disablerepo=\*

    for file in *; do dnf install -y –disablerepo=\* $file; done

  3. and to create my own repo and enable it via –enablerepo.

    I combined your solution with the one here: https://sam.hooke.me/note/2018/08/installing-rpms-offline-using-a-local-yum-repository/

    my final for-loop looked like this:

    for pkg in $(cat updates.txt | sed -e ‘s:\.[^./]*$::’); do echo >> dnf-install.out 2>&1; echo ‘==== Installing pkg ${pkg} ====’>> dnf-install.out 2>&1;echo>> dnf-install.out 2>&1; dnf install -y –disablerepo=\* –enablerepo=offline-updates –verbose $pkg >> dnf-install3.out 2>&1; done

    where updates.txt was a created using

    dnf repoquery –upgrade –queryformat ‘%{name}.%{arch}’ > updates.txt

LEAVE A REPLY

Please enter your comment!
Please enter your name here

22,858FansLike
437FollowersFollow
16SubscribersSubscribe

Latest Articles

Suggested

How to create your own Minecraft Server

Minecraft is a well-known sandbox game for a variety of purposes. It's simple to pick up and practice, gives you the freedom to do anything you want in the game, is virtually limitless, and allows you to create whatever you want if you have the imagination.

Featured

More Articles Like This