Ubuntu: install packages from CD

by on January 12, 2013 at 10:18 pm

Recently I installed a system with Ubuntu Server, and neglected to install openssh-server.  While I had terminal access, I didn’t have internet access, so I simply couldn’t run apt-get to install the missing packages.  I was stuck in the data center (virtually stuck, anyway) with a decision:  Spending another 40 minutes re-installing the operating system, or somehow install the packages from the installation disk.  I chose the latter, and while it took more time than just re-installing the system to figure it out, it will surely save me time in the long run as this is most likely not the last time I will encounter this missing package problem.

If you’re like me, you try to do things right the first time, so executing these steps might be a little foreign to you.  My hangup was the fact that RHEL/CentOS come with openssh-server installed by default, whereas Ubuntu does not.  A carefree click-through of the installation media caused me a lot of grief, but in the end I learned a valuable skill.

There is a utility called apt-cdrom which will allow you to use a cd/dvd as a repository.  I’m going to assume you have the install cd/dvd inserted into your machine.  I will try to follow up at some point with instructions for an ISO.

As root, simply run apt-cdrom add at the terminal.  This will scan your installation media, and configure a bunch of stuff in the background.  It should also create a new entry in your /etc/apt/sources.list file for the CD, and mount the disk at /media/apt.  If Ubuntu’s own documentation was of any use (is it ever?), we should be done, and simply run apt-get install <package>.  Unfortunately, that was not the case for me.

After running the apt-cdrom command, rename /etc/apt/sources.list to /etc/apt/sources.list.old

mv /etc/apt/sources.list /etc/apt/sources.list.old

Now, in the text editor of your choice (I prefer vi/vim), create a new text file with the following entry.

deb file:/media/apt/ lucid main

This system was 10.04, Lucid Lynx.  Subsitute lucid for whatever the name of your distro is.  If you look in the directory /media/apt/dists/ there should be another directory with that name.

Now you can install which ever package you wish that is available from the install media with the apt-get command.

FYI: the actual location of the .deb packages is in <cd>/pool/main/…  

Tip:  Be sure to replace your sources.list file to the original version after you are finished, and comment out the CD portion if you no longer wish to use the CD as a repo.

Looking for a similar solution for RHEL/Centos?  Check out this page (coming soon).

in Distros, How-To, Ubuntu

, , , ,

You can skip to the end and leave a response. Pinging is currently not allowed.