Skip to content

Instantly share code, notes, and snippets.

@bradfa
Last active March 27, 2017 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradfa/3d5e5912f8403d72ed67e6089f95c066 to your computer and use it in GitHub Desktop.
Save bradfa/3d5e5912f8403d72ed67e6089f95c066 to your computer and use it in GitHub Desktop.
Debian Mirror Notes

To use debmirror to update using rsync which will create a local mirror for the following:

  • arch: amd64 and all
  • dists: jessie, jessie-updates, stretch, stretch-updates, and sid
  • sections: main and main/debian-installer
  • check signatures using the debian-archive-keyring gpg keyring
  • include sources
  • store mirror in /var/www/html/debian/ directory
  • use lighttpd to export a /debian/ directory holding the contents
  • use /etc/debmirror.conf to define options
debmirror --keyring=/usr/share/keyrings/debian-archive-keyring.gpg

Mirroring oldstable, stable, testing, and unstable (along with repsective -updates) dists is about 270 GB. Removing oldstable from the list is about 210 GB.

Idea is to do one big first sync on a fast connection which may take a few hours, and then be able to do smaller daily syncs on my slow home connection to just get what's changed every night.

Using DNS on my home network, return the IP address of the local mirror for lookups of httpredir.debian.org and make sure all Debian machines are using that for their apt fetching needs. This will allow devices to not realize they're pulling from a local mirror and not the actual httpredir.debian.org round robin mirror system.

For the main section mirroring like this, to support getting contrib and non-free from the web from some other mirror, we can just call out another "deb" line in apt.conf which doesn't use httpredir.debian.org.

Do a sync of the mirror every night at 11:15 pm, in crontab put:

# Every night at 11:15 pm, update local debmirror and pipe output to syslog/journal
15  23 *   *   *     /usr/bin/debmirror --keyring=/usr/share/keyrings/debian-archive-keyring.gpg | /usr/bin/logger -t debmirror
# The config file is a perl script so take care to follow perl syntax.
# Any setting in /etc/debmirror.conf overrides these defaults and
# ~/.debmirror.conf overrides those again. Take only what you need.
#
# The syntax is the same as on the command line and variable names
# loosely match option names. If you don't recognize something here
# then just stick to the command line.
#
# Options specified on the command line override settings in the config
# files.
# Location of the local mirror (use with care)
$mirrordir="/var/www/html/debian";
# Output options
$verbose=0;
$progress=1;
$debug=0;
# Download options
$host="mirrors.kernel.org";
# $user="anonymous";
# $passwd="anonymous@";
$remoteroot="debian";
$download_method="rsync";
@dists="oldstable,oldstable-updates,stable,stable-updates,testing,testing-updates,unstable";
@sections="main,main/debian-installer";
@arches="all,amd64";
# @ignores="";
# @excludes="";
# @includes="";
# @excludes_deb_section="";
# @limit_priority="";
$omit_suite_symlinks=0;
$skippackages=0;
# @rsync_extra="doc,tools";
$i18n=0;
$getcontents=0;
$do_source=1;
$max_batch=0;
# @di_dists="dists";
# @di_archs="arches";
# Save mirror state between runs; value sets validity of cache in days
$state_cache_days=0;
# Security/Sanity options
$ignore_release_gpg=0;
$ignore_release=0;
$check_md5sums=0;
$ignore_small_errors=0;
# Cleanup
$cleanup=0;
$post_cleanup=1;
# Locking options
$timeout=300;
# Rsync options
$rsync_batch=200;
$rsync_options="-aIL --partial";
# FTP/HTTP options
$passive=0;
# $proxy="http://proxy:port/";
# Dry run
$dry_run=0;
# Don't keep diff files but use them
$diff_mode="use";
# The config file must return true or perl complains.
# Always copy this.
1;
@bradfa
Copy link
Author

bradfa commented Mar 23, 2017

Need to enable the dir-listing module in lighttpd. Setup mirror at /var/www/html/debian/ directory.

Don't create the /var/www/html/debian directory, just let rsync do it, but make sure that the user/group running debmirror has write ability to /var/www/html/ directory.

@bradfa
Copy link
Author

bradfa commented Mar 24, 2017

debmirror on Jessie seems to lock up when trying to mirror anything except "stable" or "jessie" dist. Trying to mirror both stable and stable-updates and/or any combination of testing and unstable would result is just 100% of one CPU core being used and no progress visible even with the --progress option. I left it once for over an hour.
Upgrading the mirror machine to stretch seems to bring in a debmirror which works fine.

This seems to be this bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=808216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment