it-artikel:linux:how-to-make-an-ubuntu-or-debian-apt-repository-locally-available-as-an-emergency-offline-fallback
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | it-artikel:linux:how-to-make-an-ubuntu-or-debian-apt-repository-locally-available-as-an-emergency-offline-fallback [2022-08-31 12:30] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== How to make an Ubuntu or Debian apt repository locally available as an emergency offline fallback ====== | ||
+ | |||
+ | |||
+ | Maybe you never had that problem yourself, but there may be reasons why someone want to have one or multiple Ubuntu or Debian online repositories available on your local network. Maybe because you throw an Linux installation party and dozens of times the same repos and files are been pulled over a thin DSL connection. Or you want your own local mirror in case your internet connection goes down. Or you might just want to keep a certain version or snapshot of the online repo for a specific UBUNTU release or distro, because one day it may become unavailable, | ||
+ | |||
+ | So how to achieve that ? | ||
+ | |||
+ | As always, there is more than just one solution. However... this is how i did it. | ||
+ | |||
+ | ===== Pre-Requirements: | ||
+ | |||
+ | - Define what distro releases and what " | ||
+ | #deb url distroReleaseName repo/ | ||
+ | deb http:// | ||
+ | </ | ||
+ | - Take a note what official Ubuntu/ | ||
+ | * :!: **BEWARE: This manual assumes the use of only ONE official mirror server, for all distros or releases we want! This is somewhat important, since later we only want to make one single directory available to our network clients.** The **apt-mirror** tool however creates one directory per official mirror, which makes it more complex and is not shown here. So avoid the use of several different mirror servers and only use a single one if possible. | ||
+ | - Make sure your have PLENTY of disk space available for each distro release and repositories you select. Depending on your choices it can easily exceed 500GB total as in my example here. | ||
+ | |||
+ | ===== Installation and configuration: | ||
+ | |||
+ | - :!::!::!: **BUG: It seems that the '' | ||
+ | - Install the special **apt-mirror** fork from [[https:// | ||
+ | cd /opt/ | ||
+ | git clone https:// | ||
+ | ln -vs / | ||
+ | </ | ||
+ | - Prepare your download/ | ||
+ | mkdir -p / | ||
+ | chown -c apt-mirror.users / | ||
+ | chmod -c u+rwx, | ||
+ | </ | ||
+ | - Make your own version of **/ | ||
+ | cp / | ||
+ | |||
+ | cat << ' | ||
+ | ############# | ||
+ | # | ||
+ | set base_path | ||
+ | # | ||
+ | # set mirror_path | ||
+ | # set skel_path | ||
+ | # set var_path | ||
+ | set cleanscript $var_path/ | ||
+ | # set defaultarch | ||
+ | # set postmirror_script $var_path/ | ||
+ | # set run_postmirror 0 | ||
+ | set nthreads | ||
+ | set _tilde 0 | ||
+ | # | ||
+ | ############# | ||
+ | |||
+ | ################################## | ||
+ | ## | ||
+ | ## UBUNTU 16.04 LTS (xenial) | ||
+ | ## | ||
+ | ################################## | ||
+ | |||
+ | deb http:// | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | |||
+ | deb-i386 http:// | ||
+ | deb-i386 http:// | ||
+ | deb-i386 http:// | ||
+ | deb-i386 http:// | ||
+ | deb-i386 http:// | ||
+ | |||
+ | ################################## | ||
+ | ## | ||
+ | ## UBUNTU 18.04 LTS (bionic) | ||
+ | ## | ||
+ | ################################## | ||
+ | |||
+ | deb http:// | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | |||
+ | deb-i386 http:// | ||
+ | deb-i386 http:// | ||
+ | deb-i386 http:// | ||
+ | deb-i386 http:// | ||
+ | deb-i386 http:// | ||
+ | |||
+ | |||
+ | ################################## | ||
+ | ## | ||
+ | ## UBUNTU 20.04 LTS (focal) | ||
+ | ## | ||
+ | ################################## | ||
+ | |||
+ | deb http:// | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | |||
+ | deb-i386 http:// | ||
+ | deb-i386 http:// | ||
+ | deb-i386 http:// | ||
+ | deb-i386 http:// | ||
+ | deb-i386 http:// | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ################################## | ||
+ | ## | ||
+ | ## GLOBAL / CLEANUP | ||
+ | ## | ||
+ | ################################## | ||
+ | |||
+ | clean http:// | ||
+ | clean http:// | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | EOF | ||
+ | </ | ||
+ | - Apt-mirror does not come with a **postmirror.sh** script, even though its called by default on every mirroring. So to prevent the error message, we create our own script:< | ||
+ | cat << EOF > / | ||
+ | #!/bin/bash -e | ||
+ | |||
+ | ## Anything in this file gets run AFTER the mirror has been run. | ||
+ | ## Put your custom post mirror operations in here (like rsyncing the installer | ||
+ | ## files and running clean.sh automatically)! | ||
+ | |||
+ | EOF | ||
+ | </ | ||
+ | - For automatic updating your local mirrors, use crontab. In my case, i want to update my local mirrors once a day at 1am: < | ||
+ | cat << EOF > / | ||
+ | # | ||
+ | # Regular cron jobs for the apt-mirror package | ||
+ | # | ||
+ | # | ||
+ | 0 1 * * * apt-mirror / | ||
+ | |||
+ | EOF | ||
+ | </ | ||
+ | - :!: **WARNING: | ||
+ | - Start the first run/ | ||
+ | # this will run apt-mirror as service user ' | ||
+ | # use CTRL+C to abort download if needed. Else let it do its job and | ||
+ | # check back 24h later. | ||
+ | # | ||
+ | su - -c / | ||
+ | </ | ||
+ | - If the download is done, your local repo has been created and should be ready at **/ | ||
+ | - To access it from your local network by clients you'll need some sort of webserver or ftp server. Its your choice. Just make sure, it can access (read only) your mirrored files using its service account. This manual assumes we use Apache and use its Ubuntu default webserver directory: < | ||
+ | # make symbolic link for Apache to reach the mirror dirs. | ||
+ | ln -s / | ||
+ | ln -s / | ||
+ | </ | ||
+ | - In my example my Ubuntu mirror should be available to my network clients under **%%http:// | ||
+ | |||
+ | # Example for UBUNTU 19.04 DISCO | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | |||
+ | deb http:// | ||
+ | |||
+ | |||
+ | </ | ||
+ | cat << EOF > / | ||
+ | |||
+ | # Example for UBUNTU 20.04 FOCAL | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | deb http:// | ||
+ | |||
+ | deb http:// | ||
+ | |||
+ | EOF | ||
+ | </ | ||
+ | - Now do a '' | ||
+ | |||
+ | I hope this helps someone. | ||
+ | |||
+ | --- // | ||
+ | |||
+ | {{tag> | ||
+ | |||
+ | |||
it-artikel/linux/how-to-make-an-ubuntu-or-debian-apt-repository-locally-available-as-an-emergency-offline-fallback.txt · Last modified: 2022-08-31 12:30 by 127.0.0.1