Pages

Saturday, April 30, 2011

How to create an offline Ubuntu repository

Debmirror program  creates a local mirror of a Deban repository. A quick way to build an offline repository, save it to to an USB drive, and use it on a computer without internet access:

  1. Install the application on a computer with internet:
    $ sudo apt-get install debmirror
    
  2. Get the key for the repository and add it to the keyring. This can be done be importing it from a debian keyring:
    $ gpg --no-default-keyring --keyring /home/USER/.gnupg/trustedkeys.gpg --import /usr/share/keyrings/ubuntu-archive-keyring.gpg
    
  3. Download the repository (approximate sizes for different repositories can be found in the man page):
    $ sudo debmirror -a i386 --no-source -s main -h ro.archive.ubuntu.com -d natty,natty-updates,natty-security -r /ubuntu --progress -e http mirror
    
    This mirrors section main of Ubuntu 11.04 Natty, updates and security  All options are explained in the man page.
  4. Mount usb device containing the repository to the other computer:
    $ mount /dev/sdb1 /mnt/usb
    
  5. Create a backup copy of sources.list file and modify it:
    $ sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
    $ sudo vim /etc/apt/sources.list
    
    Delete all content and add just:
    deb file:///mnt/usb/mirror natty main
    deb file:///mnt/usb/mirror natty-updates main
    deb file:///mnt/usb/mirror natty-security main
    
  6. Retrieve the new list of packages from the offline repository:
    $ sudo apt-get update
    
  7. Upgrade the repository:
    $ sudo apt-get upgrade
    
  8. Start installing packages....

1 comment: