Skip to content

Instantly share code, notes, and snippets.

@Aryangh1379
Last active December 26, 2024 13:11
Show Gist options
  • Save Aryangh1379/4f4f543ff054f6b69cc9ddd4cef4f9c2 to your computer and use it in GitHub Desktop.
Save Aryangh1379/4f4f543ff054f6b69cc9ddd4cef4f9c2 to your computer and use it in GitHub Desktop.

Archlinux Packages Cache Server Implementation

1. Squid Cache Server

2. Pacman CacheServer feature

2.1 - Using NFS (Failure, not supported by pacman)


sudo pacman -S nfs-utils

aryan@archian:~$ cat /etc/exports
# /etc/exports - exports(5) - directories exported to NFS clients
#
# Example for NFSv3:
#  /srv/home        hostname1(rw,sync) hostname2(ro,sync)
# Example for NFSv4:
#  /srv/nfs4        hostname1(rw,sync,fsid=0)
#  /srv/nfs4/home   hostname1(rw,sync,nohide)
# Using Kerberos and integrity checking:
#  /srv/nfs4        *(rw,sync,sec=krb5i,fsid=0)
#  /srv/nfs4/home   *(rw,sync,sec=krb5i,nohide)
#
# Use `exportfs -arv` to reload.
/srv/nfs        192.168.1.0/24(rw,fsid=root)
/srv/nfs/pkg  192.168.1.0/24(ro,sync)
/srv/nfs/info  192.168.1.0/24(ro,sync)
/srv/nfs/home  192.168.1.0/24(ro,sync)
#/srv/nfs/home   192.168.1.0/24(rw,sync)

sudo mkdir -p /srv/nfs/pkg
sudo mount --bind /var/cache/pacman/pkg/ /srv/nfs/
sudo systemctl restart nfsv4-server.service
  • mount with

2.2 - Nginx HTTP Server

# sudo pacman -S nginx

Enter these lines:

/etc/nginx/nginx.conf:
    [...]
        location / {
            autoindex on;
            root   /var/cache/pacman/pkg;
    [...]

Check configuration & Start the service:

# nginx -t 
# systemctl start nginx
  • bonus point: restart nginx with: nginx -s reload

Client Setup:

add the line under each repository in pacman configuraiton: /etc/pacman.d/ OR /etc/pacman.conf

CacheServer  = http://192.168.1.3
  • also it's disk space efficient if you direct to the tmp directory on client so it doesnt store cached pkgs. CacheDir = /tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment