Software Repository Mirror: Difference between revisions

From IHRIS Wiki
No edit summary
 
(46 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This article describes how to create a repository of the Ubuntu software.  This would be useful for downloading the Ubuntu software library to a hard drive for installation of Ubuntu when there is a slow internet connection (or none at all).
This has been adapted from [https://help.ubuntu.com/community/Debmirror these instructions].  You will need a 200GB external hard drive that you can reformat.
'''WARNING:''' This has not been fully tested.  Please correct or send feedback to "litlfred@ibiblio.org"
==Preparing the Hard Drive==
==Preparing the Hard Drive==
In the directions below we will assume that you have a brand new hard drive.  We will be formatting the hard drive (partition) which means that all of the data on the hard drive will be lost.
In the directions below we will assume that you have a brand new hard drive.  We will be formatting the hard drive (partition) which means that all of the data on the hard drive will be lost.
Line 63: Line 69:
===Labelling the hard drive===
===Labelling the hard drive===
Now we want to make a lablel for our newly formatted hard drive so that we can refer to it easily later:
Now we want to make a lablel for our newly formatted hard drive so that we can refer to it easily later:
  sudo tune2fs -L ihris /dev/'''sdb1'''
  sudo tune2fs -L ihris /dev/sdb1


===Testing===
===Testing===
Unplug the hard drive and plug it back in.  There should be a USB disk icon on your Desktop with the label "ihris".  Also, running:
Unplug the hard drive and plug it back in.  There should be a USB disk icon on your Desktop with the label "ihris".  Also, running:
  mount | grep medai
  mount | grep media
you should see somethine like:
you should see somethine like:
  /dev/sdc1 on /media/ihris type ext3 (rw,nosuid,nodev,uhelper=udisks)
  /dev/sdc1 on /media/ihris type ext3 (rw,nosuid,nodev,uhelper=udisks)
Line 75: Line 81:
You should now have you hard drive prepared and mounted under /media/ihris.  If not '''STOP'''
You should now have you hard drive prepared and mounted under /media/ihris.  If not '''STOP'''
===Mirroring===
===Mirroring===
We will be mirroring (creating an indentical copy of the online ubunto repositories).  All of the packages will be saved into a subdirectory of our hard drive which we create with:
We will be mirroring (which means to create an identical copy of) the online Ubuntu repositories and the [https://launchpad.net/~intrahealth+informatics/+archive/ihris iHRIS PPA] on Launchpad.  All of the packages for Ubuntu and iHRIS will be saved into a subdirectories of our hard drive which we create with:
  mkdir -p /media/ihris/ubunruMirror/mirror
  sudo mkdir -p /media/ihris/ubuntuMirror/mirror
We also need to create a directory for our key ring
  sudo mkdir -p /media/ihris/ubuntuMirror/mirroriHRIS
  mkdir -p /media/ihris/ubunruMirror/keyring


We will also need to install the debmirror software:
sudo apt-get install debmirror


====mirror.sh====
===mirrorbuild.sh===
Save the script below to /media/ihris/ubuntuMirror/mirrorbuild.sh by copying and pasting with gedit:
Save the script below to /media/ihris/ubuntuMirror/mirrorbuild.sh by copying and pasting with gedit:
  sudo gedit  /media/ihris/ubuntuMirror/mirrorbuild.sh
  sudo gedit  /media/ihris/ubuntuMirror/mirrorbuild.sh
Line 90: Line 97:
basePath="/media/ihris/ubuntuMirror/"
basePath="/media/ihris/ubuntuMirror/"


#
# Don't touch the user's keyring, have our own instead
# Don't touch the user's keyring, have our own instead
#
export GNUPGHOME=${basePath}keyring
export GNUPGHOME=${basePath}keyring


# Outpath=              # Directory to store the mirror in
# Outpath=              # Directory to store the mirror in
# Make this a full path to where you want to mirror the material.
#
outPath=${basePath}mirror
outPath=${basePath}mirror
# Arch=        -a      # Architecture. For Ubuntu can be i386, powerpc or amd64.
# sparc, only starts in dapper, it is only the later models of sparc
#
#arch=i386,amd64
arch=amd64


# Minimum Ubuntu system requires main, restricted
# Minimum Ubuntu system requires main, restricted
# Section=      -s      # Section (One of the following - main/restricted/universe/multiverse).
# Section=      -s      # Section (One of the following - main/restricted/universe/multiverse).
#
section=main,restricted,universe
section=main,restricted,universe


# Release=      -d      # Release of the system (Dapper, Edgy, Feisty, Gutsy), and the -updates and -security ( -backports can be added if desired)
# Release of the system (Dapper, Edgy, Feisty, Gutsy), and the -updates and -security ( -backports can be added if desired)
release=oneiric,oneiric-updates,oneiric-security,
release=oneiric,oneiric-updates,oneiric-security,precise,precise-updates,precise-security
#  When Ubuntu 12.04 (LTS Precise) is released, you should use this instead
#release=oneiric,oneiric-updates,oneiric-security,precise,precise-updates,precise-security


# Server=      -h      # Server name, minus the protocol and the path at the end
# You can change this to a faster/closer mirror if you wish
# CHANGE "*" to equal the mirror you want to create your mirror from. au. in Australia  ca. in Canada.
# This can be found in your own /etc/apt/sources.list file, assuming you have Ubuntu installed.
#
server=us.archive.ubuntu.com
server=us.archive.ubuntu.com


# The --nosource option only downloads debs and not deb-src's
 
# The --progress option shows files as they are downloaded
#start the mirror of iHRIS packages on launchpad ppa http://ppa.launchpad.net/intrahealth+informatics/ihris/ubuntu
# --source \ in the place of --no-source \ if you want sources also.
debmirror      -a i386,amd64 --no-source -s main -h ppa.launchpad.net -r  intrahealth+informatics/ihris/ubuntu -d natty --progress -e http ${outPath}iHRIS
# Start script
#start the mirroring of ubuntu
#
debmirror      -a i386,amd64 --no-source -s $section -h $server -d $release --progress -e http $outPath
debmirror      -a $arch --no-source -s $section -h $server -d $release \
                --progress -e http $outPath


</source>
</source>
Line 134: Line 123:


===Trusting the Ubuntu Archives===
===Trusting the Ubuntu Archives===
We need to set up our mirroring software to trust all of Ubuntu's software archives.  This can be done with:
We need to create a directory for our key ring and up our mirroring software to trust all of Ubuntu's software archives.  This can be done with:
  sudo  gpg --keyring /usr/share/keyrings/ubuntu-archive-keyring.gpg --export --homedir /media/ihris/ubuntuMirror/keyring/ | sudo gpg --no-default-keyring --keyring trustedkeys.gpg --import --homedir /media/ihris/ubuntuMirror/keyring/
sudo mkdir -p /media/ihris/ubuntuMirror/keyring
 
sudo chmod 700 /media/ihris/ubuntuMirror/keyring
==sources.list==
  sudo  gpg --keyring /usr/share/keyrings/ubuntu-archive-keyring.gpg --export --homedir /media/ihris/ubuntuMirror/keyring/ \
The file /etc/apt/sources.list tells apt-get where to look for software packages to install.
| sudo gpg --no-default-keyring --keyring trustedkeys.gpg --import --homedir /media/ihris/ubuntuMirror/keyring/
 
We will want to have two versions of the sources.list file.  One that will use the hard drive (sources.list.harddrive) and one that will use the internet (sources.list.internet).  You will need to create a file /etc/apt/sources.list.harddrive
 
 
===sources.list.internet===
The default ubuntu installation assumes that you are connected to the interent.  So we will simply copy the existing /etc/apt/sources.list to sources.list.internet
sudo cp /etc/apt/sources.list /etc/apt/sources.list.internet
 
===sources.list.hardrive===
We now need to create a version of the sources.list that will use the hard drive.
echo "deb file:///media/ihris/" `lsb_release -cs` "main universe " | sudo tee /etc/apt/sources.list.harddrive
 
==Updating the Software Repository==
 
==Using the Software Repository==
 


===Trusting the iHRIS Launchpad PPA===
To trust the iHRIS PPA on Launchpad we do:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6EC21546
sudo  gpg --keyring  /etc/apt/trusted.gpg  --export  6EC21546 --homedir /media/ihris/ubuntuMirror/keyring/ \
| sudo gpg --no-default-keyring --keyring trustedkeys.gpg --import --homedir /media/ihris/ubuntuMirror/keyring/


===source.list.hardrive as sources.list===
==Downloading the Software Repository==
Did you copy the /etc/apt/sources.list to /etc/apt/sources.list.internet as described above?  If not '''STOP'''
To create your own mirror you can now simply use the command
Let's switch to use the hard drive
  sudo sh /media/ihris/ubuntuMirror/mirrorbuild.sh
  sudo cp /etc/apt/sources.list.harddrive /etc/apt/sources.list


This is the same command that you can use to update your mirror.


===Installing Software===
==Installing Software From The Mirrors==
First we refresh the list of available packages that apt-get knows about
First we refresh the list of available packages that apt-get knows about
  sudo apt-get update
echo "deb file:///media/ihris/ubuntuMirror/mirror" `lsb_release -cs` "main universe " | sudo tee /media/ihris/ubuntuMirror/sources.list
Now we can install package XXXXX from our hard drive by:
echo "deb file:///media/ihris/ubuntuMirror/mirroriHRIS natty main  " | sudo tee  -a /media/ihris/ubuntuMirror/sources.list
  sudo apt-get install XXXXX
  sudo apt-get -o Dir::Etc::sourceparts=nonexistent -o Dir::Etc::sourcelist=/media/ihris/ubuntuMirror/sources.list update
Now we can install package '''XXXXX''' from our hard drive by:
  sudo apt-get -o Dir::Etc::sourceparts=nonexistent -o Dir::Etc::sourcelist=/media/ihris/ubuntuMirror/sources.list install '''XXXXX'''


===source.list.internet as sources.list===
[[Category:Installation]][[Category:Review2013]]
Now that we are done, we should restore our original /etc/apt/sources.list
sudo cp /etc/apt/sources.list.internet /etc/apt/sources.list

Latest revision as of 12:46, 7 October 2013

This article describes how to create a repository of the Ubuntu software. This would be useful for downloading the Ubuntu software library to a hard drive for installation of Ubuntu when there is a slow internet connection (or none at all).

This has been adapted from these instructions. You will need a 200GB external hard drive that you can reformat.

WARNING: This has not been fully tested. Please correct or send feedback to "litlfred@ibiblio.org"

Preparing the Hard Drive

In the directions below we will assume that you have a brand new hard drive. We will be formatting the hard drive (partition) which means that all of the data on the hard drive will be lost. PLEASE MAKE SURE YOU KNOW EXACTLY WHAT YOU ARE DOING IN EACH STEP

To format the partition, we will first need to set the partition type

Determining the Hard Drive Paritition

To format the hard drive, we first to know what "partition" it is using. Ubuntu should automatically mount the hard drive should automatically once you plug it in. To determine run the command:

mount | grep media

Running this on my machine, I see output

/dev/sdb1 on /media/3539-6663 type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks)

Which means the /dev/sdb1 is the partition we will need to use.

If you see more than one line in the output then STOP as these directions may not be correct. If you see more than one line here, you probably have more than one external hard drive or flash disk connected. Remove all extra hard drive and rerun the "grep" command. If you still see more than one line, Please contact one of the of the iHRIS developers for more help.

Change The Hard Drive Partition Type

We will need to run the "fdisk" command interactively on the hard drive device. If the parition was /dev/sdb1, the hard drive device is /dev/sdb (remove the number from the partition). Here is a sample interaction. You should type in everything in bold (changing /dev/sdb as neeeded):

litlfred@cumin:/tmp$ sudo fdisk /dev/sdb
Command (m for help): p

Disk /dev/sdb: 1015 MB, 1015808000 bytes
13 heads, 36 sectors/track, 4239 cylinders, total 1984000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008db47

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     1983999      990976    6  FAT16

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 83
Changed system type of partition 1 to 83 (Linux) 

Command (m for help): p 

Disk /dev/sdb: 1015 MB, 1015808000 bytes
13 heads, 36 sectors/track, 4239 cylinders, total 1984000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008db47 

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     1983999      990976   83  Linux

Command (m for help): w
The partition table has been altered! 

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.

Formatting The Hard Drive as ext3

Simply do:

sudo mkfs.ext3  /dev/sdb1


Labelling the hard drive

Now we want to make a lablel for our newly formatted hard drive so that we can refer to it easily later:

sudo tune2fs -L ihris /dev/sdb1

Testing

Unplug the hard drive and plug it back in. There should be a USB disk icon on your Desktop with the label "ihris". Also, running:

mount | grep media

you should see somethine like:

/dev/sdc1 on /media/ihris type ext3 (rw,nosuid,nodev,uhelper=udisks)

Don't worry if your partition has changed from /dev/sdb1 to something else like /dev/sdc1

Creating the Software Repository

You should now have you hard drive prepared and mounted under /media/ihris. If not STOP

Mirroring

We will be mirroring (which means to create an identical copy of) the online Ubuntu repositories and the iHRIS PPA on Launchpad. All of the packages for Ubuntu and iHRIS will be saved into a subdirectories of our hard drive which we create with:

sudo mkdir -p /media/ihris/ubuntuMirror/mirror
sudo mkdir -p /media/ihris/ubuntuMirror/mirroriHRIS

We will also need to install the debmirror software:

sudo apt-get install debmirror

mirrorbuild.sh

Save the script below to /media/ihris/ubuntuMirror/mirrorbuild.sh by copying and pasting with gedit:

sudo gedit  /media/ihris/ubuntuMirror/mirrorbuild.sh

This is what you should copy and paste <source lang='bash'>

  1. !/bin/bash
    1. Setting variables with explanations.

basePath="/media/ihris/ubuntuMirror/"

  1. Don't touch the user's keyring, have our own instead

export GNUPGHOME=${basePath}keyring

  1. Outpath= # Directory to store the mirror in

outPath=${basePath}mirror

  1. Minimum Ubuntu system requires main, restricted
  2. Section= -s # Section (One of the following - main/restricted/universe/multiverse).

section=main,restricted,universe

  1. Release of the system (Dapper, Edgy, Feisty, Gutsy), and the -updates and -security ( -backports can be added if desired)

release=oneiric,oneiric-updates,oneiric-security,precise,precise-updates,precise-security

  1. You can change this to a faster/closer mirror if you wish

server=us.archive.ubuntu.com


  1. start the mirror of iHRIS packages on launchpad ppa http://ppa.launchpad.net/intrahealth+informatics/ihris/ubuntu

debmirror -a i386,amd64 --no-source -s main -h ppa.launchpad.net -r intrahealth+informatics/ihris/ubuntu -d natty --progress -e http ${outPath}iHRIS

  1. start the mirroring of ubuntu

debmirror -a i386,amd64 --no-source -s $section -h $server -d $release --progress -e http $outPath

</source> Note, when Ubuntu 12.04 (LTS Precise) is soon released, you should comment out the line about the release in the above section.

Trusting the Ubuntu Archives

We need to create a directory for our key ring and up our mirroring software to trust all of Ubuntu's software archives. This can be done with:

sudo mkdir -p /media/ihris/ubuntuMirror/keyring 
sudo chmod 700 /media/ihris/ubuntuMirror/keyring 
sudo  gpg --keyring /usr/share/keyrings/ubuntu-archive-keyring.gpg --export --homedir /media/ihris/ubuntuMirror/keyring/ \
| sudo gpg --no-default-keyring --keyring trustedkeys.gpg --import --homedir /media/ihris/ubuntuMirror/keyring/

Trusting the iHRIS Launchpad PPA

To trust the iHRIS PPA on Launchpad we do:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6EC21546
sudo  gpg --keyring  /etc/apt/trusted.gpg  --export  6EC21546 --homedir /media/ihris/ubuntuMirror/keyring/ \
| sudo gpg --no-default-keyring --keyring trustedkeys.gpg --import --homedir /media/ihris/ubuntuMirror/keyring/

Downloading the Software Repository

To create your own mirror you can now simply use the command

sudo sh /media/ihris/ubuntuMirror/mirrorbuild.sh

This is the same command that you can use to update your mirror.

Installing Software From The Mirrors

First we refresh the list of available packages that apt-get knows about

echo "deb file:///media/ihris/ubuntuMirror/mirror" `lsb_release -cs` "main universe " | sudo tee /media/ihris/ubuntuMirror/sources.list
echo "deb file:///media/ihris/ubuntuMirror/mirroriHRIS natty main  " | sudo tee  -a /media/ihris/ubuntuMirror/sources.list
sudo apt-get -o Dir::Etc::sourceparts=nonexistent -o Dir::Etc::sourcelist=/media/ihris/ubuntuMirror/sources.list update

Now we can install package XXXXX from our hard drive by:

sudo apt-get -o Dir::Etc::sourceparts=nonexistent -o Dir::Etc::sourcelist=/media/ihris/ubuntuMirror/sources.list install XXXXX