
So, I thought I should maybe switch to Arch Linux… of course, the correct way to start is by setting up your own Arch Linux mirror at home, you know, just the right thing an Arch user would do. Can’t install Arch Linux over netboot without a mirror, right? :D
For added amusement, we’ll set up the mirror on an Ubuntu server. You know, a rock solid LTS server distro and such. :D
The first thing you’ll wanna do, is create a directory where you’ll want to host your mirrors, and within that directory, one for archlinux (this way it will be easier to mirror other things in the future as well):
mkdir -p /var/www/mirrors/archlinux/
Now, you’ll want a Tier 1 mirror to mirror from. That’s because Arch Linux does not want you to mirror off of Arch Linux directly, so we’ll respect that and pick one from this list:
https://archlinux.org/mirrors/tier/1
Once you picked your mirror (in my case RWTH Aachen), copy the rsync URL and rsync that thing (perhaps in a screen session, since the first sync will take a while and will need a little over 100 GB at the time of this writing):
rsync -rlptH --safe-links --delete-delay --delay-updates rsync://ftp.halifax.rwth-aachen.de/archlinux/ /var/www/mirrors/archlinux/
Cool, cool! We now got a copy of all of Arch Linux. :D
Next, we’ll install Nginx and a module that will allow us to generate a nice looking directory index:
sudo apt install nginx libnginx-mod-http-fancyindex
Edit: /etc/nginx/sites-available/mirror.example.net
:
server {
listen 80;
listen [::]:80;
server_name mirror.example.net;
root /var/www/mirrors;
location / {
fancyindex on;
fancyindex_exact_size off;
try_files $uri $uri/ =404;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name mirror.example.net;
root /var/www/mirrors;
location / {
fancyindex on;
fancyindex_exact_size off;
try_files $uri $uri/ =404;
}
ssl_protocols TLSv1.3;
ssl_ecdh_curve X25519:prime256v1:secp384r1;
ssl_prefer_server_ciphers off;
ssl_certificate /etc/letsencrypt/live/example.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.net/privkey.pem;
}
Make sure to set up a certificate instead of just copying the config, and edit the server name, too. You can follow my guide here on how to get a certificate.
If you don’t want HTTPS, you can also just remove that second server block entirely.
Note: You absolutely should run a HTTP mirror and *not* force or redirect to HTTPs. This is because in some cases, HTTPS will not work. An example of this is when running the official Arch Linux netboot iPXE which will only support plain HTTP but not HTTPS.
Once you set up your config, enable it like this:
ln -s /etc/nginx/sites-available/mirror.example.net /etc/nginx/sites-enabled/mirror.example.net
Then check that the config is right:
nginx -t
And if it is, reload Nginx and navigate to your mirror domain.
systemctl reload nginx
If you end up seeing a nice index of all files, you can proceed to installing Arch Linux from your own mirror. You’ll never have seen netboot go as fast before!
I run this blog in my free time. If this helped you out, feel free to donate a cup of coffee. :3
Edit: I was on an extreme time limit so this article didn’t turn out as nice as I wanted it to, and I forgot to mention about adding the rsync command to your crontab (or a systemd timer) to keep syncing once an hour. I recommend to just copy your original rsync command to your crontab at a random minute if you want it quick and dirty so that it runs once an hour. I might flesh out this article at some point in the future but this should give you a good starting point. (:
Leave A Comment