User Tools

Site Tools


linux:aptoffline

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:aptoffline [2023/02/08 01:51] olaflinux:aptoffline [2023/02/12 17:16] (current) olaf
Line 1: Line 1:
 +===== Create a repository to update an offline system  =====
 +
 +When running a Debian system (Debian, Ubuntu, Cumulus, ...) without internet connection, it cannot receive upgrades with ''apt update && apt upgrade -y''\\
 +But with any Debian based system that is online, it is possible to download the required packages and dependencies (!).
 +
 +Maybe the source for the latest required repository changed. Therefore, it might be needed to update /etc/apt/sources.list
 +
 +''apt-get dist-upgrade'' is adding and removing packages if necessary - that doesn't matter on the online system when creating the repository, but it might be important on the offline system:
 +try on a non-production system first. Using ''apt-get upgrade'' on the offline system will not add nor remove packages but "hold back" (not update) packages that require to add or remove not installed packages. 
 +
 +Create the required directory structure on the online and offline system
 +
 +<code bash>
 +mkdir /var/spool/repo-offline
 +mkdir /var/spool/repo-offline/archives
 +mkdir /var/spool/repo-offline/archives/partial
 +mkdir /var/spool/repo-offline/lists
 +mkdir /var/spool/repo-offline/lists/partial
 +mkdir /var/spool/repo-offline/<preferences.d>
 +mkdir /var/spool/repo-offline/<apt.conf.d>
 +</code>
 +Copy following files from the offline system to /var/spool/repo-offline/ on the online system (note /etc/apt/trusted.gpg.d/ is the whole directory)
 +
 +<code bash>
 +/etc/apt/trusted.gpg.d/
 +/etc/apt/sources.list
 +/etc/apt/trusted.gpg
 +/var/lib/dpkg/status
 +</code>
 +
 +On the **offline** system create the file ''/var/spool/repo-offline/apt.conf''
 +<code bash>
 +cat > /var/spool/repo-offline/apt.conf
 +APT
 +{
 +  Get::Download-Only "false";
 +};
 +
 +Dir
 +{
 +  /* point to the file containing the current versions */
 +  State "/var/lib/dpkg/";
 +  State::status "status";
 +
 +  /* set cache location */
 +  Cache::archives "/var/spool/repo-offline/archives/";
 +
 +  /* point to the configuration directory */
 +  Etc "/var/spool/repo-offline/";
 +};
 +</code>
 +
 +Close cat with <CTRL-d>
 +
 +On the **online** system create a similar file ''/var/local/repo-offline/apt.conf''
 +<code bash>
 +cat > /var/spool/repo-offline/apt.conf
 +APT
 +{
 +  Get::Download-Only "true";
 +};
 +
 +Dir
 +{
 +  /* point to the file containing the current versions */
 +  State "/var/spool/repo-offline/";
 +  State::status "status";
 +
 +  /* set cache location */
 +  Cache::archives "/var/spool/repo-offline/archives/";
 +
 +  /* point to the configuration directory */
 +  Etc "/var/spool/repo-offline/";
 +};
 +
 +</code>
 +Close cat with <CTRL-d>
 +==== Create the repository on the online system ====
 +
 +<code bash>
 +export APT_CONFIG="</var/spool/repo-offline/apt.conf>"
 +apt-get update
 +apt-get --no-download dist-upgrade
 +</code>
 +
 +When apt is finished downloading, copy the whole directory /var/local/repo-offline/, **except** the files ''**apt.conf**'' and ''status'' to the offline system
 +==== Upgrade the offline system ====
 +<code bash>
 +export APT_CONFIG="</var/spool/repo-offline/apt.conf>"
 +apt-get check
 +apt-get dist-upgrade
 +</code>
 +