How to create a local apt repo mirror using apt-mirror
From Leo's Notes
Last edited on 3 January 2022, at 06:13.
The easiest way to create an apt-get mirror is to use apt-mirror
.
Setup
On a debian/ubuntu machine, run:
# apt-get install apt-mirror
Configure
apt-mirror
will read /etc/apt/mirror.list
as its configuration file. Below is the mirror file I currently am using:
# This is the mirror.list configuration used by apt-mirror
#
# To create a local apt repository, put this in /etc/apt/mirror.list
# then run apt-mirror
#
############# config ##################
#
# set base_path /var/spool/apt-mirror
#
set mirror_path /mnt/file
# set skel_path $base_path/skel
# set var_path $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch <running host architecture>
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads 20
set _tilde 0
#
############# end config ##############
# Mate desktop stuff
deb http://packages.mate-desktop.org/repo/ubuntu quantal main
deb-src http://packages.mate-desktop.org/repo/ubuntu quantal main
# Main ubuntu stuff
deb http://mirror.cpsc.ucalgary.ca/mirror/ubuntu.com/packages/ubuntu quantal main restricted main/debian-installer restricted/debian-installer
deb http://mirror.cpsc.ucalgary.ca/mirror/ubuntu.com/packages/ubuntu quantal-updates main restricted main/debian-installer restricted/debian-installer
deb http://mirror.cpsc.ucalgary.ca/mirror/ubuntu.com/packages/ubuntu quantal-backports main restricted main/debian-installer restricted/debian-installer
deb http://mirror.cpsc.ucalgary.ca/mirror/ubuntu.com/packages/ubuntu quantal-security main restricted main/debian-installer restricted/debian-installer
# Salt stack stuff
deb http://ppa.launchpad.net/saltstack/salt/ubuntu quantal main
Usage
Once you've defined your mirror.list
file, run apt-mirror
to create a copy of the mirrors. It will tell you the amount of data it will need to download along with the statuses of each thread that is running.
root@host# apt-mirror
Downloading 81 index files using 20 threads...
Begin time: Mon Apr 29 12:00:09 2013
[20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]... [10]... [9]... [8]...
End time: Mon Apr 29 12:00:10 2013
Proceed indexes: [SPPPPPP]
219.8 MiB will be downloaded into archive.
Downloading 639 archive files using 20 threads...
Begin time: Mon Apr 29 12:00:18 2013
[20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]... [10]... [9]... [8]...
End time: Mon Apr 29 12:00:47 2013
0.0 bytes in 0 files and 0 directories can be freed.
Run /var/spool/apt-mirror/var/clean.sh for this purpose.
Running the Post Mirror script ...
(/var/spool/apt-mirror/var/postmirror.sh)
Post Mirror script has completed. See above output for any possible errors.
You have new mail in /var/mail/root