Home Package management How To Fully Update And Upgrade Offline Debian-based Systems Using Apt-offline

How To Fully Update And Upgrade Offline Debian-based Systems Using Apt-offline

Apt-offline - An Offline APT Package Manager For Debian And Derivatives

By sk
22.3K views

A while ago, we have shown you how to install software in an offline Ubuntu Linux system. Today, we will see how to fully update and upgrade offline Debian-based systems using Apt-offline utility. Unlike the previous method, we do not update/upgrade a single package, but the whole system. This method can be helpful in situations where you have slow Internet speed or don't have an active Internet connection at all.

Introduction

Picture  this scenario. You have a system (Windows or Linux) with high-speed Internet connection at work and a Debian or any Debian-based systems with no internet connection or very slow Internet connection at home.

You want to upgrade your offline home system. What would you do? Buy a high speed Internet connection? Not necessary! You still can update or upgrade your offline Debian-based system without Internet. This is where Apt-Offline comes in help.

What Is Apt-offline?

Apt-offline is an Offline APT Package Manager for APT based systems like Debian and Debian derived distributions such as Ubuntu, Linux Mint.

Using Apt-offline, we can install, update, and upgrade packages along with the dependencies on a Debian-based system that has no Internet connection.

Apt-offline is cross-platform tool written in the Python Programming Language and has both CLI and graphical interfaces.

Requirements

  • An Internet-connected system (Windows or Linux). We call it "online system" for the sake of easy understanding throughout this guide.
  • An "Offline system" (Debian and Debian-derived system).
  • USB drive or External Hard drive with sufficient space to carry all updated packages.

Install Apt-offline In Debian, Ubuntu

Apt-Offline is available in the default repositories of Debian and derivatives. If your Online system is running with Debian, Ubuntu, Linux Mint, and other DEB based systems, you can install Apt-Offline using command:

$ sudo apt install apt-offline

If your Online system runs with a distro other than Debian, git clone Apt-Offline repository:

$ git clone https://github.com/rickysarraf/apt-offline.git

Go the directory and run it from there.

$ cd apt-offline/
$ sudo ./apt-offline

Install Apt-offline In Offline System

If your offline system has slow Internet speed, you can install Apt-offline using APT package manager as shown above. But, what if that system is not connected with Internet? No problem. In that case, go to any Internet-enabled system, and download apt-offline.deb file from the Official releases page or pkgs.org website. Copy the .deb file to a USB drive, and then go back to the offline system and finally install it using command:

$ sudo dpkg -i apt-offline_1.8.5_all.deb

If it didn't work for any reason, you still can download the Apt-offline package along with all dependencies on any Internet-enabled system and install it on the Offline system as described in the following guide.

Well, we have now installed Apt-offline on both Online and Offline systems.

Update And Upgrade Offline Debian-based System With Apt-offline

Upgrading Offline Debian system consists of the following steps:

  1. Go to the Offline system, create a directory (E.g. PkgUpdates) and generate the database of files that are required for an update.
  2. Copy the PkgUpdates directory to the Online system and download all the package updates based on the database files.
  3. Finally, transfer the downloaded updates via USB or copy them using any file transfer utilities to the Offline system and install the updates.

1. Generate Signature Of Packages In Offline system (Non-Internet connected system)

Go to your offline system and create a directory to generate and store the signature file for the packages to be upgraded.

$ mkdir ~/PkgUpdates
$ cd ~/PkgUpdates

You can use any directory of your choice. Then, run the following command to generate the signature file:

$ sudo apt-offline set apt-offline.sig

Sample output:

Gathering details needed for 'update' operation
Gathering details needed for 'upgrade' operation
Generate Signature File Using Apt-offline
Generate Signature File Using Apt-offline

By default, apt-offline will generate database of files that are needed to be updated and upgraded. You can also use --update or --upgrade options to create database for either one of these.

Copy the entire PkgUpdates folder in an USB drive or external drive and go to your online system(i.e. Internet-enabled system).

Heads Up: If both online and offline systems are in the same local network, you can transfer the PkgUpdates folder to the offline system using "scp" or any other file transfer applications.

$ scp -r PkgUpdates/ user@ip:/path/to/desitnation

If both systems are in different places, copy the folder using an USB drive.

2. Download Package Updates Using Apt-offline In Online System

Plug in your USB drive and go to the PkgUpdates directory:

$ cd PkgUpdates/

Then, run the following command:

$ sudo apt-offline get apt-offline.sig --threads 5 --bundle apt-offline-bundle.zip

Here, "--threads 5" represents the number of APT repositories. You can increase the number if you want to download packages from more repositories. And, the "--bundle apt-offline-bundle.zip" option represents all packages will be bundled in a single archive file called apt-offline-bundle.zip. This archive file will be saved in your current working directory i.e. PkgUpdates.

The above command will download data based on the signature file generated earlier in the offline system.

Download Package Updates Using Apt-offline
Download Package Updates Using Apt-offline

This will take several minutes depending upon the Internet connection speed. Please note that apt-offline is cross platform, so you can use it to download packages on any OS.

Once package download process is completed, you will see an output like below:

[...]
349 / 349 items: [##############################] 100.0% of 344 MiB
Downloaded data to /home/ostechnix/PkgUpdates/apt-offline-bundle.zip

The updates are bundled in a zip file called apt-offline-bundle.zip and saved in the PkgUpdates directory. You can verify it with ls command:

$ ls
apt-offline-bundle.zip  apt-offline.sig

Now, copy the whole PkgUpdates directory to the USB drive, unplug the USB or external drive and go back to your offline system.

Make sure your USB device has enough free space to save the whole PkgUpdates directory, because all downloaded packages are saved in the that directory.

You can also copy the PkgUpdates folder to the offline using scp or any other file transfer utility to the offline if the online and offline systems are located in the same LAN.

3. Apply Package Updates Using Apt-offline In Offline System

Plug-in the USB device in your offline system and go to the PkgUpdates directory where you have downloaded all packages earlier.

$ cd PkgUpdates

Then, run the following command to install all download packages.

$ sudo apt-offline install apt-offline-bundle.zip

This will update and populate the APT database with downloaded packages in your offline system, so APT will find all required packages in the APT cache.

Sample output:

[...]
security.debian.org_debian-security_dists_bullseye-security_main_binary-amd64_Packages.xz synced.
security.debian.org_debian-security_dists_bullseye-security_main_i18n_Translation-en.xz synced.
security.debian.org_debian-security_dists_bullseye-security_non-free_binary-all_Packages.xz synced.
security.debian.org_debian-security_dists_bullseye-security_non-free_binary-amd64_Packages.xz synced.
security.debian.org_debian-security_dists_bullseye-security_non-free_i18n_Translation-en.xz synced.
Apply Package Updates Using Apt-offline
Apply Package Updates Using Apt-offline

Conclusion

This is how we fully update or upgrade an offline Debian or Debian-based systems with the help of Apt-offline application. This can be really useful in environments where you manage hundreds of offline Debian-based systems. You can simply download the updates from an Internet-connected system and apply the updates on the non-internet connected Debian-based systems.

Resource:

You May Also Like

9 comments

ro ni January 9, 2019 - 2:03 pm

well, you missed the part where you install apt-offline on the *offline* system, didn’t you?

Reply
jayrugman April 22, 2019 - 11:34 pm

I’m with ro ni. This seems like a crucial step. Any update on getting apt-offline on the “offline” system?

Reply
Thorsten Schöning May 20, 2019 - 11:04 am

Installing “apt-offline” offline should be as easy as cloning the repo using GIT to the USB-drive needed for the packages anyway.

Reply
sk November 12, 2019 - 6:11 pm

Good catch. I have updated the guide now. Thanks for pointing it out.

Reply
Keith December 30, 2023 - 11:52 pm

Great article but there is still the final missing step:-
sudo apt upgrade

Reply
D September 11, 2022 - 5:56 am

Great guide for earlier versions of Ubuntu, but `sudo apt-get upgrade` and `sudo apt upgrade` will no longer install the apt-offline cache because it fails to resolve on the ubuntu repositories (because the system is offline). Weirdly though, `sudo apt-get install ` still works at finding the packages previously loaded into cache from apt-offline.

Any thoughts on this? Thanks.

Reply
sk September 11, 2022 - 11:32 am

If Internet is connected in your Ubuntu machine, you can install apt-offline using apt package manager. If Internet is not available, download the apt-offline.deb package from other Internet-connected systems and then try to install it using dpkg command as described in the guide.

Reply
Ron May 10, 2023 - 6:49 am

Hi, does this upgrade Ubuntu OS from 20 to 22? I tried but it just update packages…

Reply
sk May 11, 2023 - 10:31 am

No. It will only update and upgrade the packages of the currently installed DEB-based OS.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More