Home Fedora How to Offline Update Fedora Workstation

How to Offline Update Fedora Workstation

by Arun Kumar
August 2020 Articles (Estimated 4 articles) Deposit Amount is approx. The actual amount will be adjusted based on project completion status.

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.

You may also like

3 comments

Steven Stetka May 13, 2021 - 4:20 PM

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.

Reply
Steven Stetka May 13, 2021 - 6:04 PM

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

Reply
Steven Stetka May 13, 2021 - 9:45 PM

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

Reply

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.