Introduction#
I installed the unofficial ArchLinux ARM on my Raspberry Pi 4. Hosting the caching proxy can be done on any OS and any architecture, so here it doesn't matter that the server will be ARMv7 based when the proxy client will be x86_64 ones.
Purpose#
I have several machines using ArchLinux on my local networks (desktop, laptop,
2 VMs) so every day when running an update with pacman -Syu
I fetch all the
packages from Internet (WAN) several times, which is useless, is a waste of
bandwidth (in my case not really an issue as I have a 1 Gbps fiber connection)
but the main bottleneck is the mirrors upstream bandwidth that can be quite low
sometimes.
So here we will configure an ArchLinux package caching proxy on my Raspberry Pi 4 and all my ArchLinux machines will use it as a pacman mirror, so the 1st ArchLinux machine will still requires to fetch packages from the WAN but all other ArchLinux machines will be able to fetch the same packages from LAN at the speed of light as the packages would have previously been cached.
Pros:
- Save WAN downstream bandwidth
- Download ArchLinux packages from LAN at high speed
- Way more efficient for home usage than setting up a full pacman mirror
- Easier to setup and smarter than a cache with a classical web server like nginx or darkhttpd (see Read-only cache or Dynamic reverse proxy cache using nginx)
- 24/7 available thanks to the client/server architecture rather than a Distributed cache between clients
- Embedded automatic purge timer (pacoloco) rather than having to manually setup purge service using paccache (flexo)
Install#
As a caching proxy for pacman I chose pacoloco which is available on the AUR so we can install it with a Pacman wrapper.
Example:
Configuration#
Caching server#
Edit /etc/pacoloco.yaml
:
As we are running a Raspberry Pi with a 32 GB MicroSD card it's important
to set purge_files_after
with a low value so the caching server disk will not
get full. For other options see pacoloco - Configure.
Of course it's recommended you use mirrors near you for performance, to do that you can use Reflector.
pacoloco is totally capable of caching Unofficial user repositories or overlay repositories for ArchLinux like BlackArch.
ArchLinux clients#
For ArchLinux official repositories, edit /etc/pacman.d/mirrorlist
and put
the following line on top of all other mirror servers:
For the BlackArch repository, edit /etc/pacman.d/blackarch-mirrorlist
and put
the following line on top of all other mirror servers:
Running#
Then we just start the service:
Then all is automatic, the first ArchLinux client using pacman -Syu
will
ask the caching proxy to fetch the databases & package for it, but as soon as
the second client will ask for the same packages they will be served from
the caching proxy on the LAN rather than fetched from the Internet (WAN).