Ubuntu – How to update Ubuntu offline without using Synaptic or Keryx

package-managementsoftware-centerupdates

I use Ubuntu 12.04 at my home and have good internet connection and my system works fine.

One of my friend is having small office and he is thinking to switch from Windows to Ubuntu 11.10 or above. The problem is that he does not have an Internet connection.

He ask me that is there any possibilities to install all updates without having Internet. I make many search, I found this question that says using Keryx or Synaptic Manager will do that.

But I am using 11.04 and there is no Synaptic manager in that so that I generate and download script.In other way when I try to install keryx (on any fresh install system on which I have to fetch the updates or system having Internet connection)
enter image description here

Its shows me error that I am not having python.But I am having that

enter image description here

Installing these application doesn't meet dependencies. The key point here is

  • How I Install updates without having internet on fresh install Ubuntu.
  • How I install ubuntu-restricted-extras

Best Answer

As far as I know, you can't download updates for a Oneiric (11.10) system using Ubuntu Natty (11.04). You must have a working Ubuntu 11.10 system.

An sketch about the process we are following:

  1. First we'll install a Virtual machine in OP's Natty (11.04) system.
  2. We'll install Ubuntu 11.10 in that virtual machine
  3. We'll setup virtual machine to have a common shared folder between the host OS (11.04) and the guest OS (11.10)
  4. We will generate a download script of packages which are required to upgrade that system (guest OS i.e Ubuntu 11.10).
  5. We'll transfer the download script to the host OS using shared folder set up in step 3.
  6. In host OS, we'll download all the required packages with the help of download script we get in step 5.
  7. We'll transfer all the downloaded .deb files in the Offline system, that is actual Ubuntu 11.10 system in his friend's PC.
  8. We'll create a local repository in his friend's PC with those packages.
  9. We'll upgrade OP's friends Ubuntu with the help of local repository created in step 8.

1. Getting a working Oneiric system

There are two ways to have a working Oneiric system.

  • By Doing an actual installation

    You have to install Ubuntu Oneiric (11.10) on the computer with Internet connection. Though it is also possible from a live system running from USB or CD, I recommend installing. You can get help for installing Ubuntu from these links:

  • Installing Oneiric in a VirtualBox Virtual Machine

    1. To install VirtualBox in Ubuntu 11.04 Natty Narwhal, run these commands in a terminal:

      sudo apt-get update
      sudo apt-get install virtualbox
      
    2. Then install Oneiric in the virtual machine.

    3. Set up a shared folder in the virtual machine.

      You need to install VirtualBox Guest Additions to enable shared folder feature. Run this command in the virtual machine to install that:

      sudo apt-get install virtualbox-guest-additions
      

      If you need help enabling the shared folders feature in the VirtualBox, check this link:

2. Grab the .deb files required for updates

Please Note these specific points:

  1. It is recommended not to update the virtual system during installation or afterwards before installing Synaptic. Cause, those updates might be deleted from cache and without those updates, you can't successfully generate package download script.

  2. Don't run sudo apt-get clean or sudo apt-get autoclean, because those commands removes .deb files from cache.

Then boot to the Oneiric system that has an Internet connection (either from the installed system or in VirtualBox) and follow this procedure:

  1. Install Synaptic Package Manager. Run these commands in a terminal for this: (Note, You must connect the virtual machine to the Internet, without Internet access the machine cannot update the package list)

     sudo apt-get update 
     sudo apt-get install synaptic
    

    You may also want to download the packages required for the ubuntu-restricted-extras package. To do so, Run this command additionally with the previous two commands

     sudo apt-get install -d ubuntu-restricted-extras
    

    This command will not install the packages, it only downloads them with all dependencies in /var/cache/apt/archives folder.

  2. Then open Synaptic Package Manager. Push the button Mark All Upgrades.
    image of upgrade push button

  3. When asked if you want to Mark additional required chanages, press the Mark button.
    image of additional mark window

  4. Then going to File --> Generate package download script, save the script as a file. Let it be update-downloader.sh in a folder named Updates. We assume the Updates folder is in your home directory, i.e., in /home/username. Then close Synaptic.

  5. Now download the .deb files.

    1. Go to the Updates folder, where you saved update-downloader.sh.

    2. While you are still in the Terminal and have cd'd to the Updates folder you created earlier, run this command:

      cp /var/cache/apt/archives/*.deb .
      

      That copies the downloaded .deb files which are used for installing Synaptic Package Manager and the files downloaded for the ubuntu-restricted-extras package.

    3. Then run this command sh ./update-downloader.sh to download all the .deb files required to update in the current folder (i.e., in the Updates folder.

      Or

      Alternatively, you can transfer the Updates folder with the few .deb files you just copied from /var/cache/apt/archives with the update-downloader.sh script in it to the host OS via VirtualBox's shared folder feature.

      Then in the host Ubuntu system, open a terminal and run the below command by going to the Updates folder you just copied from the guest OS using shared folder feature, where update-downloader.sh file resides:

      sh ./update-downloader.sh
      
    4. If you downloaded the .deb files in the virtual machine, in this step, transfer the Updates folder with those files using Virtual Box's shared folder feature. (This step is only required if you downloaded the files in virtual machine)

    5. After you get the Updates folder with all .deb files in your host PC (i.e., in your Natty system) copy that folder with all files on a USB flash drive. You may also want to burn a DVD with those packages, though I am not recommending that.

    6. Transfer the Updates folder using your USB drive (or CD/DVD, if you burned them) to your friend's PC.

3. Use the .deb files to create a local repository

Copy the whole folder named Updates to the Internet-less computer. Put that folder in a directory. Let say, you have put the Updates folder in the home directory. Create a new directory in your home folder with name offline, and move the Updates folder into the offline folder. Now, the directory structure looks like this

   + home 
     +- username
       +-  offline
         +-  Updates (contains the .deb files)
 

  1. Now open a terminal and go to the offline folder. Once in the offline folder, run this command to generate the necessary package index file:

    apt-ftparchive packages . > Packages
    

    It will create a file with name Packages.

  2. Now open /etc/apt/sources.list file with root power. In a terminal do this

    gksu gedit /etc/apt/sources.list
    
  3. Then press an Enter while your cursor is at the beginning of the file. This will create a new blank line at the top. Write this line as the first line in the file

    deb file:/home/username/offline /

    Then save the file with Ctrl+S and exit gedit, the text editor.

    Remember to use the exact folder / path names for the offline folder, and replace username with login name of the user.

    Also, if you are sure, your friend cannot use other repository sources, you may want to disable all other repositories by placing a # mark before each line in the /etc/apt/sources.list file. (This is not actually required, but recommended).

    Note that it is generally required to put a local repository at the top of the file, to give it a higher preference then other repository sources. (But in this particular case, you might be able to get away with not doing this, since your friend can't even connect to the Internet to access any of the other configured repositories.)

4. Do the update without accessing the Internet!

  1. Run sudo apt-get update in the terminal to make the package manager recognize your local update directory.

  2. Then do this command to upgrade the offline system:

     sudo apt-get upgrade --allow-unauthenticated
    

Done! You have upgraded your system without Internet access.


Some Notes:

1. Don't want to write allow-unauthenticated option every time?

If you want to use this local repository to install packages time to time, but feel bored to always use that allow-unauthenticated option, do this.

Create a file named 99mysettings in /etc/apt/apt.conf.d with gedit and add the line in that file and save.

    APT::Get::AllowUnauthenticated "true";

To open a file named 99mysettins in that directory with root power use this command in a terminal

gksu gedit /etc/apt/apt.conf.d/99mysettings

2. Note about allow-unauthenticated option:

You might wonder why I have provided the --allow-unauthenticated option. This is used because your local update repository is not authentic to the system. But it will not harm, because you downloaded those packages from an authentic official Ubuntu repository.

3. I want to have a trusted repository instead:

Check this awesome and epic post in Ubuntu forums about creating a trusted local repository. If you create a trusted repository, you don't have to provide --allow-unauthenticated option anymore.

Recommendation: I would recommend you not to use PPA repositories, unless you really trust them. In particular, don't use experimental repositories, because they may introduce dependency problems in the system, which is often referred by Unix geek as dependency hell. This can be harder to fix when you do not have an Internet connection.