With Linus surrendering to the forces that will consume Linux, it’s time to rethink a few things and make some decisions now that could save our nerd bacon, at least locally.

This is for primarily Debian based distributions but all good distros have something in place to help with mirroring.

What you will need:
1. A Debian-based server with plenty of space.
2. Sudo access to the server.
3. Some time.

What I assume:
You know about Debian’s apt repository system. You are familiar with Linux command line and basic administration.

Difficulty level: Low to Medium.

Install apt-mirror.

> sudo apt-get install apt-mirror apache2

Using your preferred editor, edit /etc/apt/mirror.list

Add the repos you want to mirror. For example, if you want to mirror the older Jessie packages, you’d have something like the following:

deb http://deb.debian.org/debian jessie main contrib non-free
deb-src http://deb.debian.org/debian jessie main contrib non-free
deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free

Once you are ready to download the packages for mirroring run

> su - apt-mirror -c apt-mirror

It’s going to take a while. If you have a slow connection, it’s going to take even longer. For the first time, I ran it overnight when I ran it. It will put the mirror data in /var/spool/apt-mirror/mirror/

Once it’s done creating the mirror, you can serve it up through Apache.

For example:

> ln -s /var/spool/apt-mirror/mirror/ftp.us.debian.org/debian /var/www/debian
> ln -s /var/spool/apt-mirror/mirror/security.debian.org/debian-security /var/www/debian-security

Now, on the machine you want to use the local mirror, edit the apt sources to point to the mirror server.

Edit /etc/apt/sources.list

If you are setting it up for the server running the mirror, you can do something like this:

deb http://localhost/debian etch main contrib non-free
deb-src http://localhost/debian etch main contrib non-free
deb http://localhost/debian-security etch/updates main contrib non-free
deb-src http://localhost/debian-security etch/updates main contrib non-free

If you are setting up a different server, replace localhost with the machine’s name.

After that:

> sudo apt-get update

And you’ll be pulling packages from your very own mirror.

If things look stupid, just stop updating your main mirror and you will have working code that could potentially keep going even if the kernel gains diversity, good and hard.