5

Is there a recommended process for being able to install Ubuntu packages along their transitive dependencies, in an air-gapped IT environment having no direct Internet connectivity?

I can think of two challenges -

  1. Bundling up each package of interest along its recursive set of dependencies, for delivery into the air-gapped environment

  2. Setting up the target Ubuntu servers not to look for packages from the Internet but rather using the bundle from (1), or, setting up an internal download service which the target servers will reach out to instead of the Internet servers normally serving up packages

Your comments much appreciated!

matanox
  • 1,861

2 Answers2

6

Apt can use repositories on your local file system.

You would need to create the repo and know the packages you want to install on a computer with Internet access and apt-get.

apt-get -d install [packages]
mkdir /media/usb/MyRepo
cp -a /var/cache/apt/archives/*.deb /media/usb/MyRepo
dpkg-scanpackages /media/usb/MyRepo /dev/null > /media/usb/MyRepo/Packages

Now MyRepo can act as a repository. Transfer the directory to the system you need to install on such as on a USB drive. Then

echo "deb file:///media/usb/MyRepo ./" > /etc/apt/sources.list.d/myrepo.list
apt-get update
apt-get install [packages]

There are other tools that you can install separately such as apt-medium for shared caches, apt-mirror for mirroring repos etc.

jdwolf
  • 1,086
2

apt-offline

You can use apt-offline to install packages on an air-gapped host or to update/upgrade it. This tool is very handy, because it does not require the same Ubuntu version on both hosts (online/air-gapped).

Prerequisites

  1. Install apt-offine on your online host:

    sudo apt install apt-offline
    
  2. Download apt-offline for your air-gapped host from:

    https://packages.ubuntu.com/jammy/all/apt-offline/download

    Make sure to replace jammy by the actual codename of your air-gapped host. You can query it with lsb_release -c.

  3. Transfer the downloaded apt-offline package to your air-gapped host and install it:

    sudo dpkg -i apt-offline_1.8.4-1_all.deb
    

Update

To update the package lists on your air-gapped host:

  1. Create a signature file for that task on your air-gapped host:

    sudo apt-offline set apt-offline.sig --update
    
  2. Move that file to your online host and download the files for an offline update:

    apt-offline get apt-offline.sig --bundle bundle.zip
    
  3. Move the bundle from your online host to your air-gapped host and install it:

    sudo apt-offline install bundle.zip
    

Install packages

To install packages on your air-gapped host, just do the same as for updating, but create a signature file for installation instead. E. g. for packages git and g++:

sudo apt-offline set apt-offline.sig --install-packages git g++

After you imported the bundle on your air-gapped host, you can run apt install as usual:

sudo apt install git g++

Upgrade

To upgrade your air-gapped host, just do the same as for updating, but create a signature file for upgrade instead:

sudo apt-offline set apt-offline.sig --upgrade

After you imported the bundle on your air-gapped host, you can run apt upgrade as usual:

sudo apt upgrade