Size: 6436
Comment: moved from my home at KarlGoetz on w.u.c
|
Size: 7369
Comment: I think every six hours is a bit extreme. made it 12, i think it should be daily
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
## page was renamed from DebmirrorHowto | |
Line 7: | Line 8: |
This is not covering all use cases but it will allow you experiment. To do this safely 8.2 gigs of space are need main source and binaries. This number grows a lot as time progresses. | This is not covering all use cases but it will allow you experiment. To do this safely 8.2 gigs of space are needed to mirror main source and binaries. This number grows a lot as time progresses. |
Line 11: | Line 12: |
If you want to download all the apt binaries for all boxes onto one box on a network then maybe apt-cache or a transparent proxy is all you need. | If you want to download all the apt binaries for all boxes onto one box on a network then maybe apt-cache or a transparent proxy (eg [http://help.ubuntu.com/community/HttpReplicator http-replicator] is all you need. Another method is to use rsync. The [http://help.ubuntu.com/community/Rsyncmirror Rsyncmirror] page goes into greater detail on this method. Rsync can create a full mirror of a site and selects files indiscriminately. Debmirror, however, does allow for better control over which packages are mirrored and can be easier on the amount of hard drive space required. |
Line 17: | Line 20: |
[[BR]]Open your sources list (sudo editor /etc/apt/sources.list), and add the following line [[BR]]deb http://*.archive.ubuntu.com/ubuntu/ dapper universe |
[[BR]]Open your sources list (sudo sensible-editor /etc/apt/sources.list), and add the following line [[BR]]deb http://cc.archive.ubuntu.com/ubuntu/ dapper universe |
Line 20: | Line 23: |
[[BR]]In the example above, cc is your countrys code (eg au means Australia), and dapper is replaced with the release your using. | |
Line 22: | Line 26: |
[[BR]] Now we have to create a directory to save the files too. The aproximate size of the components of the mirror (i386 only) are: # Cant have these at teh end of lines - they break the formatting. # dapper is approx including sources. (not including restricted) |
[[BR]] Now we have to create a directory to save the files too. The approximate size of the components of the mirror (i386 only) are: |
Line 26: | Line 28: |
# Changes over time. || dapper || 8.2G || main || || dapper-security || ?G || main, restricted, universe, multiverse || || dapper-updates || ?G || main, restricted, universe, multiverse || || breezy || 11G || main || || breezy-security || 493M || main, restricted, universe, multiverse || || breezy-updates || 182M || main, restricted, universe, multiverse || || hoary || ~9G || main || || hoary-security || 1.2G || main, restricted, universe, multiverse || || hoary-updates || 144M || main, restricted, universe, multiverse || |
|| feisty || ~27G || main, restricted, universe, multiverse || || dapper || 15G || main, restricted, universe, multiverse || |
Line 44: | Line 39: |
== Create the file `mirrorBuild.sh` == | == Create the file `mirrorbuild.sh` == |
Line 46: | Line 41: |
Now to create `mirrorBuild.sh` | Now to create `mirrorbuild.sh` |
Line 49: | Line 44: |
sudo editor /home/UbuntuMirror/mirrorBuild.sh | sudo sensible-editor /usr/local/bin/mirrorbuild.sh |
Line 51: | Line 46: |
Line 63: | Line 59: |
# # Don't touch the user's keyring, have our own instead # export GNUPGHOME=/home/mirrorkeyring |
|
Line 73: | Line 74: |
# Release= -d # Release of the system (Hoary, Breezy, Dapper, Edgy), and the -updates and -security ( -backports can be added if desired) | # Release= -d # Release of the system (Dapper, Edgy, Feisty, Gutsy), and the -updates and -security ( -backports can be added if desired) |
Line 81: | Line 82: |
server=*.archive.ubuntu.com | server=cc.archive.ubuntu.com |
Line 99: | Line 100: |
# --source \ in the place of --nosource \ if you want sources also. | # --source \ in the place of --no-source \ if you want sources also. |
Line 103: | Line 104: |
--nosource \ | --no-source \ |
Line 110: | Line 111: |
--ignore-release-gpg \ | |
Line 120: | Line 120: |
* Now change the permissions and ownership on the mirror and the script. The group name is your username: | * Now change the permissions and ownership on the mirror. The group name is your username: |
Line 125: | Line 125: |
* Set up your keyring to correctly verify Release signatures {{{ sudo mkdir /home/mirrorkeyring gpg --no-default-keyring --keyring /home/mirrorkeyring/pubring.gpg --import /usr/share/keyrings/ubuntu-archive-keyring.gpg }}} |
|
Line 127: | Line 132: |
cd /home/UbuntuMirror ./mirrorBuild.sh |
buildmirror.sh |
Line 130: | Line 134: |
Now walk away. Your machine has a lot of downloading to do! | Now walk away. Your machine has a lot of downloading to do! Seriously... it'll take hours. |
Line 145: | Line 149: |
== Add a cronjob to keep the mirror updated == If you want to keep your mirror fresh, you will want to stick your mirror script in cron. To edit root's crontab, do: {{{ sudo crontab -e }}} And now add the following line: {{{ 2 */12 * * * /usr/local/bin/mirrorbuild.sh }}} Which will run two minutes after the hour every twelve hours. MAKE SURE that there is a blank line after the line you added, otherwise it will never run. If you want to be paranoid, restart cron: {{{ sudo /etc/init.d/cron restart }}} |
|
Line 152: | Line 172: |
sudo editor sources.list | sudo sensible-editor sources.list |
ContentsBRTableOfContents(3) |
To build a mirror with debmirror follow these steps
This is not covering all use cases but it will allow you experiment. To do this safely 8.2 gigs of space are needed to mirror main source and binaries. This number grows a lot as time progresses.
Alternative Consideration
If you want to download all the apt binaries for all boxes onto one box on a network then maybe apt-cache or a transparent proxy (eg [http://help.ubuntu.com/community/HttpReplicator http-replicator] is all you need.
Another method is to use rsync. The [http://help.ubuntu.com/community/Rsyncmirror Rsyncmirror] page goes into greater detail on this method. Rsync can create a full mirror of a site and selects files indiscriminately. Debmirror, however, does allow for better control over which packages are mirrored and can be easier on the amount of hard drive space required.
Start The Mirror Build Process
Open gnome-terminal by clicking Applications -> Accessories -> Terminal. BRIf your sources list has universe enabled, skip the next step. BROpen your sources list (sudo sensible-editor /etc/apt/sources.list), and add the following line BRdeb http://cc.archive.ubuntu.com/ubuntu/ dapper universe BRThen save and return to a prompt. BRIn the example above, cc is your countrys code (eg au means Australia), and dapper is replaced with the release your using.
Update the package lists (sudo apt-get update) and then install debmirror (sudo apt-get install debmirror). BR Now we have to create a directory to save the files too. The approximate size of the components of the mirror (i386 only) are: # Changes over time.
feisty |
~27G |
main, restricted, universe, multiverse |
dapper |
15G |
main, restricted, universe, multiverse |
Please ensure where ever you make the mirror has room for the packages you want to download! BR(If you are more advanced you can make different parts of the mirror on different volumes, but thats not something for this howto). BRWe will make our mirror on /home/ with
sudo mkdir /home/UbuntuMirror
Create the file `mirrorbuild.sh`
Now to create mirrorbuild.sh BROpen your prefered editor thus
sudo sensible-editor /usr/local/bin/mirrorbuild.sh
Copy the text from the box below into the editor. BRYou may omit the lines starting with # (NB EXCEPTION the line that starts #!/bin/bash must be left in.)
Contents of the mirror script, please adapt it to your needs
#### Start script to automate building of Ubuntu mirror ##### ## THE NEXT LINE IS NEEDED THE REST OF THE LINES STARTING WITH A # CAN BE DELETED #!/bin/bash ## Setting variables with explanations. # # Don't touch the user's keyring, have our own instead # export GNUPGHOME=/home/mirrorkeyring # 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 # Minimum Ubuntu system requires main, restricted # Section= -s # Section (One of the following - main/restricted/universe/multiverse). # section=main,restricted,universe,multiverse # Release= -d # Release of the system (Dapper, Edgy, Feisty, Gutsy), and the -updates and -security ( -backports can be added if desired) # release=dapper,dapper-security,dapper-updates # Server= -h # Server name, minus the protocol and the path at the end # 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=cc.archive.ubuntu.com # Dir= -r # Path from the main server, so http://my.web.server/$dir, Server dependant # inPath=/ubuntu # Proto= -e # Protocol to use for transfer (http, ftp, hftp, rsync) # Choose one - http is most usual the service, and the service must be avaialbe on the server you point at. # proto=http # Outpath= # Directory to store the mirror in # Make this a full path to where you want to mirror the material. # outPath=/home/UbuntuMirror # The --nosource option only downloads debs and not deb-src's # The --progress option shows files as they are downloaded # --source \ in the place of --no-source \ if you want sources also. # Start script # debmirror -a $arch \ --no-source \ -s $section \ -h $server \ -d $release \ -r $inPath \ --progress \ -e $proto \ $outPath #### End script to automate building of Ubuntu mirror ####
How to use the file
- Save the file and exit.
- Now change the permissions and ownership on the mirror. The group name is your username:
sudo chown -R root.username /home/UbuntuMirror sudo chmod -R 571 /home/UbuntuMirror
- Set up your keyring to correctly verify Release signatures
sudo mkdir /home/mirrorkeyring gpg --no-default-keyring --keyring /home/mirrorkeyring/pubring.gpg --import /usr/share/keyrings/ubuntu-archive-keyring.gpg
- And the final part of setting up the mirror is to download the files
buildmirror.sh
Now walk away. Your machine has a lot of downloading to do! Seriously... it'll take hours.
Set up the mirror
We need to install Apache2, you could choose apache version 1.3 but that is beyond the scope of this document. BR We can do this with sudo apt-get install apache2 BR BR Then (for simplicity sake) lets make a link from /home/UbuntuMirror to /var/www/ubuntu.
ln -s /home/UbuntuMirror /var/www/ubuntu
This means when you go to download from your mirror, you will visit http://mirrorbox/ubuntu/. BR BR Right! So we have all the packages, and a working server. Now we need to set up the clients.
Add a cronjob to keep the mirror updated
If you want to keep your mirror fresh, you will want to stick your mirror script in cron. To edit root's crontab, do:
sudo crontab -e
And now add the following line:
2 */12 * * * /usr/local/bin/mirrorbuild.sh
Which will run two minutes after the hour every twelve hours. MAKE SURE that there is a blank line after the line you added, otherwise it will never run. If you want to be paranoid, restart cron:
sudo /etc/init.d/cron restart
Set up a client system
Open a terminal and enter
cd /etc/apt sudo mv sources.list sources.list.orig sudo sensible-editor sources.list
Now in your editor, put the following lines:
# Local network mirror sources. deb http://mirrorbox/ubuntu dapper main restricted universe multiverse deb http://mirrorbox/ubuntu dapper-updates main restricted universe multiverse deb http://mirrorbox/ubuntu dapper-security main restricted universe multiverse
Then save and exit BR If you then run
sudo apt-get update sudo apt-get dist-upgrade
you should be updating from your new server!