Two Degrees Of Installation – How To Offline Apt-Get In Ubuntu (and Debian-Related)

Here’s a possible situation leading to your stumbling on this post.  You’ve installed and updated Ubuntu on a machine (or 11) in a room with its one IP address already dedicated to another machine (and the building sys admin doesn’t take kindly to you sitting on a dozen or more dedicated IP addresses), you didn’t set up any NAT to feed the connection of one dedicated machine to the rest of the machines in the room, you don’t want to switch cables around because you’ve already zip-tied everything down with a Vulcan death grip and don’t want to start cutting because you can’t find free CAT6, and you don’t feel like opening /etc/network/interfaces a dozen times to reset the IP addresses and gateways on 11 machines to install one #&$@*ing piece of software you forgot on your initial install + upgrade (or, as was my case, I didn’t know that one piece of software WASN’T installed as part of the standard package).

You are in luck, with the dirty work made much, much easier if you already have an Ubuntu box online.

Installing packages in Ubuntu while offline involves (1) determining which programs and assorted libraries are required for what you want to install, (2) collecting all of the necessary install files from either the intertubes or an online Ubuntu box you can apt-get with (what I will assume here) and (3) using the Debian dpkg program instead of apt-get (which, to the best of my knowledge, is basically the same difference) to perform the installation on the offline box.  If you’ve an online Ubuntu box, then step (1) involves installing the program you want to install on the other computers so that all of the necessary install files are downloaded, sitting locally, and ready for flashdrive (or LAN) transfer (and I assume you’re running either all 32- or all 64-bit on the machines, such that the offline machine is the same as the online machine).

LEGEND

Text in black – my ramblings.

Text in bold red – things you will type in the Terminal

Text in green – text you will either see or will type into files (using pico, my preference)

I’ll be using the installation of NFS (network file system) as my example.  You’ll get a handle for what needs to be done for your own installs this way.

(1 – Online Box) Installing Program [X] On An Online Ubuntu Box With apt-get

For some programs, only one install file may be required.  Generally, however, your apt-get install will list several additional “new” and “extra” packages, often missing libraries and system files required for the installed program to run.  As you should suspect, you will need ALL of these files to install your programs on offline machines.  Fortunately, all of these packages are downloaded and saved in their installation format (.deb) locally.

For NFS, the three core installed packages I ran my initial apt-get for…

a. sudo apt-get install nfs-kernel-server nfs-common portmap

Yielded the following output

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
libevent1 libgssglue1 libnfsidmap2 librpcsecgss3
The following NEW packages will be installed:
libevent1 libgssglue1 libnfsidmap2 librpcsecgss3 nfs-common nfs-kernel-server portmap
0 upgraded, 7 newly installed, 0 to remove and 96 not upgraded.
Need to get 530kB of archives.
After this operation, 1642kB of additional disk space will be used.
Do you want to continue [Y/n]?
Get:1 http://us.archive.ubuntu.com hardy/main libevent1 1.3e-1 [49.3kB]
Get:2 http://us.archive.ubuntu.com hardy/main libgssglue1 0.1-1 [22.2kB]
Get:3 http://us.archive.ubuntu.com hardy/main libnfsidmap2 0.20-0build1 [24.7kB]
Get:4 http://us.archive.ubuntu.com hardy-updates/main librpcsecgss3 0.17-1ubuntu2 [33.8kB]
Get:5 http://us.archive.ubuntu.com hardy/main portmap 6.0-4 [34.6kB]
Get:6 http://us.archive.ubuntu.com hardy-updates/main nfs-common 1:1.1.2-2ubuntu2.2 [203kB]
Get:7 http://us.archive.ubuntu.com hardy-updates/main nfs-kernel-server 1:1.1.2-2ubuntu2.2 [162kB]
Fetched 530kB in 1s (378kB/s)
Preconfiguring packages …
Selecting previously deselected package libevent1.
(Reading database … 31771 files and directories currently installed.)
Unpacking libevent1 (from …/libevent1_1.3e-1_amd64.deb) …
Selecting previously deselected package libgssglue1.
Unpacking libgssglue1 (from …/libgssglue1_0.1-1_amd64.deb) …
Selecting previously deselected package libnfsidmap2.
Unpacking libnfsidmap2 (from …/libnfsidmap2_0.20-0build1_amd64.deb) …
Selecting previously deselected package librpcsecgss3.
Unpacking librpcsecgss3 (from …/librpcsecgss3_0.17-1ubuntu2_amd64.deb) …
Selecting previously deselected package portmap.
Unpacking portmap (from …/portmap_6.0-4_amd64.deb) …
Selecting previously deselected package nfs-common.
Unpacking nfs-common (from …/nfs-common_1%3a1.1.2-2ubuntu2.2_amd64.deb) …
Selecting previously deselected package nfs-kernel-server.
Unpacking nfs-kernel-server (from …/nfs-kernel-server_1%3a1.1.2-2ubuntu2.2_amd64.deb) …
Setting up libevent1 (1.3e-1) …

Setting up libgssglue1 (0.1-1) …

Setting up libnfsidmap2 (0.20-0build1) …

Setting up librpcsecgss3 (0.17-1ubuntu2) …

Setting up portmap (6.0-4) …
* Starting portmap daemon…
…done.

Setting up nfs-common (1:1.1.2-2ubuntu2.2) …

Creating config file /etc/idmapd.conf with new version

Creating config file /etc/default/nfs-common with new version
Adding system user `statd’ (UID 104) …
Adding new user `statd’ (UID 104) with group `nogroup’ …
Not creating home directory `/var/lib/nfs’.
* Starting NFS common utilities
…done.

Setting up nfs-kernel-server (1:1.1.2-2ubuntu2.2) …

Creating config file /etc/exports with new version

Creating config file /etc/default/nfs-kernel-server with new version
* Starting NFS common utilities
…done.
* Exporting directories for NFS kernel daemon…
…done.
* Starting NFS kernel daemon
…done.

Processing triggers for libc6 …
ldconfig deferred processing now taking place

So, from the three programs I knew I needed…

nfs-kernel-server nfs-common portmap

The following list of packages were downloaded and installed…

nfs-kernel-server nfs-common portmap libevent1 libgssglue1 libnfsidmap2 librpcsecgss3

As for NFS, the installation does not perform configuration (NFS is part of an upcoming post if interested).

Now for the .deb collection…

The default apt-get behavior is to download .deb package files and place them into /var/cache/apt/archives/, thereby greatly simplifying the offline installation process.  As of April 2009, the NFS install list is the following (version numbers will change and ignore the _amd64 if you’re on a 32-bit machine).

libevent1_1.3e-1_amd64.deb
libgssglue1_0.1-1_amd64.deb
libnfsidmap2_0.20-0build1_amd64.deb
librpcsecgss3_0.17-1ubuntu2_amd64.deb
nfs-common_1%3a1.1.2-2ubuntu2.2_amd64.deb
nfs-kernel-server_1%3a1.1.2-2ubuntu2.2_amd64.deb
portmap_6.0-4_amd64.deb

This directory may be quite full (especially if you’ve apt-get update’d lately).  You can make the search a little easier on your eyes by sorting by date (assuming the install on the “online” machine is recent and by itself).  I will assume you’re doing the transport by flashdrive.

b. ls /media
Note the [name of flashdrive] sitting in this directory
c. cd /var/cache/apt/archives/
d. ls -tl
e. cp [filename.deb] /media/[name of flashdisk]

z. umount /media/[name of flashdrive]

(2 – Offline Box) From-Flashdrive Installation

Once the flashdrive is plugged into the offline box and the terminal window is open, you’re going to copy the .deb files to a directory (I will assume your home directory, ~/) on the hard drive and then run dpkg to install them.

a. cp /media/[name of flashdrive]/*.deb ~/
b. cd ~/
c. dpkg -I *.deb

The proper output should be as follows:

Selecting previously deselected package libevent1.
(Reading database … 115620 files and directories currently installed.)
Unpacking libevent1 (from libevent1_1.3e-1_amd64.deb) …
Selecting previously deselected package libgssglue1.
Unpacking libgssglue1 (from libgssglue1_0.1-1_amd64.deb) …
Selecting previously deselected package libnfsidmap2.
Unpacking libnfsidmap2 (from libnfsidmap2_0.20-0build1_amd64.deb) …
Selecting previously deselected package librpcsecgss3.
Unpacking librpcsecgss3 (from librpcsecgss3_0.17-1ubuntu2_amd64.deb) …
Selecting previously deselected package nfs-common.
Unpacking nfs-common (from nfs-common_1%3a1.1.2-2ubuntu2.2_amd64.deb) …
Selecting previously deselected package nfs-kernel-server.
Unpacking nfs-kernel-server (from nfs-kernel-server_1%3a1.1.2-2ubuntu2.2_amd64.deb) …
Selecting previously deselected package portmap.
Unpacking portmap (from portmap_6.0-4_amd64.deb) …
Setting up libevent1 (1.3e-1) …

Setting up libgssglue1 (0.1-1) …

Setting up libnfsidmap2 (0.20-0build1) …

Setting up librpcsecgss3 (0.17-1ubuntu2) …

Setting up portmap (6.0-4) …
* Starting portmap daemon…
…done.

Processing triggers for man-db …
Setting up nfs-common (1:1.1.2-2ubuntu2.2) …

Creating config file /etc/idmapd.conf with new version

Creating config file /etc/default/nfs-common with new version
Adding system user `statd’ (UID 113) …
Adding new user `statd’ (UID 113) with group `nogroup’ …
Not creating home directory `/var/lib/nfs’.
* Starting NFS common utilities
…done.

Setting up nfs-kernel-server (1:1.1.2-2ubuntu2.2) …

Creating config file /etc/exports with new version

Creating config file /etc/default/nfs-kernel-server with new version
* Starting NFS common utilities
…done.
* Exporting directories for NFS kernel daemon…
…done.
* Starting NFS kernel daemon
…done.

Processing triggers for libc6 …
ldconfig deferred processing now taking place

And, if you happen to miss a package during the transfer, dpkg will be kind enough to tell you.  Here’s the output from my forgetting to transport libevent1_1.3e-1_amd64.deb

Selecting previously deselected package libgssglue1.
(Reading database … 115620 files and directories currently installed.)
Unpacking libgssglue1 (from libgssglue1_0.1-1_amd64.deb) …
Selecting previously deselected package libnfsidmap2.
Unpacking libnfsidmap2 (from libnfsidmap2_0.20-0build1_amd64.deb) …
Selecting previously deselected package librpcsecgss3.
Unpacking librpcsecgss3 (from librpcsecgss3_0.17-1ubuntu2_amd64.deb) …
Selecting previously deselected package nfs-common.
Unpacking nfs-common (from nfs-common_1%3a1.1.2-2ubuntu2.2_amd64.deb) …
Selecting previously deselected package nfs-kernel-server.
Unpacking nfs-kernel-server (from nfs-kernel-server_1%3a1.1.2-2ubuntu2.2_amd64.deb) …
Selecting previously deselected package portmap.
Unpacking portmap (from portmap_6.0-4_amd64.deb) …
Setting up libgssglue1 (0.1-1) …

Setting up libnfsidmap2 (0.20-0build1) …

Setting up librpcsecgss3 (0.17-1ubuntu2) …

dpkg: dependency problems prevent configuration of nfs-common:
nfs-common depends on libevent1 (>= 1.3e); however:
Package libevent1 is not installed.
dpkg: error processing nfs-common (–install):
dependency problems – leaving unconfigured
dpkg: dependency problems prevent configuration of nfs-kernel-server:
nfs-kernel-server depends on nfs-common (>= 1:1.0.8-1); however:
Package nfs-common is not configured yet.
dpkg: error processing nfs-kernel-server (–install):
dependency problems – leaving unconfigured
Setting up portmap (6.0-4) …
* Starting portmap daemon…
…done.

Processing triggers for man-db …
Processing triggers for libc6 …
ldconfig deferred processing now taking place
Errors were encountered while processing:
nfs-common
nfs-kernel-server

To review:

(1) Install Program [X] On An Online Ubuntu Box

a. sudo apt-get install [program list]
b. ls /media
c. cd /var/cache/apt/archives/
d. ls -tl
e. cp [filename.deb] /media/[name of flashdrive]

z. umount /media/[name of flashdrive]

(2) To The “Offline” Machine…

a. cp /media/[name of flashdrive]/*.deb ~/
b. cd ~/
c. dpkg -I *.deb

www.ubuntu.com
en.wikipedia.org/wiki/Network_address_translation
en.wikipedia.org/wiki/Vulcan_nerve_pinch
www.debian.org
en.wikipedia.org/wiki/Dpkg
en.wikipedia.org/wiki/Apt-get
en.wikipedia.org/wiki/Network_File_System_(protocol)

One Reply to “Two Degrees Of Installation – How To Offline Apt-Get In Ubuntu (and Debian-Related)”

Leave a Reply