proxmox-offline-mirror : créer un miroir local pour Debian et Ubuntu
Un mémo sur comment utiliser la commande proxmox-offline-mirror pour créer un miroir local pour les distributions Debian et Ubuntu.
Pour la création d’un miroir local Pour Proxmox, voir cet article : https://memo-linux.com/proxmox-offline-mirror-creer-un-miroir-local-pour-proxmox/
Créer un miroir local Debian
Pour la création d’un miroir local pour la distribution Debian, rien de compliqué car c’est intégré à la commande proxmox-offline-mirror :
proxmox-offline-mirror setup
- Select Action: dd new mirror entry
- Guided Setup ([yes]): yes
- Select distro to mirror : 4
- Select release : 0 (pour Bookworm)
- Select repository variant :
- 0) Main repository
- 1) Security
- 2) Updates
- 3) Backports
- 4) Debug Information
Dans mon cas, j’ai éxécuté la commande
proxmox-offline-mirror setup
3 fois pour avoir les 3 miroirs : Main repository, Security et Updates. - Enter repository components : main contrib (les dépots non-free c’est à vous de choisir)
- Configure filters for Debian mirror bookworm / main : – (pas de filtres dans mon cas)
- Enter mirror ID :
- debian_bookworm_main
- debian_bookworm_security
- debian_bookworm_updates
- Enter (absolute) base path where mirrored repositories will be stored : /srv/mirrors/debian/ (à adapter)
- Should already mirrored files be re-verified when updating the mirror? : yes
- Should newly written files be written using FSYNC to ensure crash-consistency? : yes
- Pour finir, Select Action : Quit
- Pour automatiser la création et la mise à jour du miroir Debian, voici le script :
nano /usr/local/bin/sync-debian.sh
#!/bin/bash export ALL_PROXY="http://proxyx.local:PORT" mirror_dir="/srv/mirrors/debian" symlink_dir="/srv/mirrors/debian/latest" proxmox-offline-mirror mirror snapshot create --config '/etc/proxmox-offline-mirror.cfg' 'debian_bookworm_main' proxmox-offline-mirror mirror snapshot create --config '/etc/proxmox-offline-mirror.cfg' 'debian_bookworm_updates' proxmox-offline-mirror mirror snapshot create --config '/etc/proxmox-offline-mirror.cfg' 'debian_bookworm_security' if [ $? -eq 0 ]; then for dir in "${mirror_dir}"/*; do if [ -d "$dir" ]; then dir_name=$(basename "$dir") if [[ "$dir_name" != "latest" && "$dir_name" != "lost+found" ]]; then latest_subdir=$(ls -td "$dir"/*/ | head -n 1) if [ -n "$latest_subdir" ]; then latest_subdir_name=$(basename "$latest_subdir") if [ -e "${symlink_dir}/${dir_name}" ]; then rm -f "${symlink_dir}/${dir_name}" fi ln -s "$latest_subdir" "${symlink_dir}/${dir_name}" fi fi fi done echo "Done on ${symlink_dir}." else echo "Error." fi
chmod +x /usr/local/bin/sync-debian.sh
sync-debian.sh
crontab -e
0 2 * * * /usr/local/bin/sync-debian.sh
Créer un miroir local Ubuntu
A la date de publication de l’article, la commande proxmox-offline-mirror setup
n’est pas opérationnelle pour créer un miroir local pour la distribution Ubuntu.
Ici, je choisis la distribution Ubuntu 24.04 LTS Noble.
- Préparation du miroir Ubuntu Noble :
- Création des répertoires pour le miroir :
mkdir -p /srv/mirrors/ubuntu/noble/{ubuntu_noble_main,ubuntu_noble_updates,ubuntu_noble_security,latest}
mkdir -p /srv/mirrors/ubuntu/noble/.pool
- Téléchargement de la clé ubuntu :
gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys F6ECB3762474EDA9D21B7022871920D1991BC93C
gpg --export F6ECB3762474EDA9D21B7022871920D1991BC93C | tee /usr/share/keyrings/ubuntu-archive-keyring.gpg > /dev/null
/etc/proxmox-offline-mirror.cfg
à la suite des autres miroirs :nano /etc/proxmox-offline-mirror.cfg
mirror: ubuntu_noble_main architectures amd64 architectures all base-dir /srv/mirrors/ubuntu/noble ignore-errors false key-path /usr/share/keyrings/ubuntu-archive-keyring.gpg repository deb https://fr.archive.ubuntu.com/ubuntu noble main restricted universe multiverse sync true verify true mirror: ubuntu_noble_updates architectures amd64 architectures all base-dir /srv/mirrors/ubuntu/noble ignore-errors false key-path /usr/share/keyrings/ubuntu-archive-keyring.gpg repository deb https://fr.archive.ubuntu.com/ubuntu noble-updates main restricted universe multiverse sync true verify true mirror: ubuntu_noble_security architectures amd64 architectures all base-dir /srv/mirrors/ubuntu/noble ignore-errors false key-path /usr/share/keyrings/ubuntu-archive-keyring.gpg repository deb https://fr.archive.ubuntu.com/ubuntu noble-security main restricted universe multiverse sync true verify true
nano /usr/local/bin/sync-ubuntu.sh
#!/bin/bash export ALL_PROXY="http://proxy.local:PORT" mirror_dir="/srv/mirrors/ubuntu/noble" symlink_dir="/srv/mirrors/ubuntu/noble/latest" proxmox-offline-mirror mirror snapshot create --config '/etc/proxmox-offline-mirror.cfg' 'ubuntu_noble_main' proxmox-offline-mirror mirror snapshot create --config '/etc/proxmox-offline-mirror.cfg' 'ubuntu_noble_updates' proxmox-offline-mirror mirror snapshot create --config '/etc/proxmox-offline-mirror.cfg' 'ubuntu_noble_security' if [ $? -eq 0 ]; then for dir in "${mirror_dir}"/*; do if [ -d "$dir" ]; then dir_name=$(basename "$dir") if [[ "$dir_name" != "latest" && "$dir_name" != "lost+found" ]]; then latest_subdir=$(ls -td "$dir"/*/ | head -n 1) if [ -n "$latest_subdir" ]; then latest_subdir_name=$(basename "$latest_subdir") if [ -e "${symlink_dir}/${dir_name}" ]; then rm -f "${symlink_dir}/${dir_name}" fi ln -s "$latest_subdir" "${symlink_dir}/${dir_name}" fi fi fi done echo "Done on ${symlink_dir}." else echo "Error." fi
chmod +x /usr/local/bin/sync-ubuntu.sh
sync-ubuntu.sh
Pour information, sous Ubuntu server 24.04 LTS les dépôts ne se renseignent plus dans le fichier :
/etc/apt/sources.list
.
cat /etc/apt/sources.list
# Ubuntu sources have moved to /etc/apt/sources.list.d/ubuntu.sources
- Modifier les URLs des dépôts :(dans mon cas le nom de domaine de mon serveur web est mirrors.local) :
nano /etc/apt/sources.list.d/ubuntu.sources
Types: deb URIs: http://mirrors.local/ubuntu/noble/latest/ubuntu_noble_main Suites: noble Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg Types: deb URIs: http://mirrors.local/ubuntu/noble/latest/ubuntu_noble_security Suites: noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg Types: deb URIs: http://mirrors.local/ubuntu/noble/latest/ubuntu_noble_updates Suites: noble-updates Components: main universe restricted multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
apt update
Hit:1 http://mirrors.local/ubuntu/noble/latest/ubuntu_noble_main noble InRelease Hit:2 http://mirrors.local/ubuntu/noble/latest/ubuntu_noble_security noble-security InRelease Hit:3 http://mirrors.local/ubuntu/noble/latest/ubuntu_noble_updates noble-updates InRelease Reading package lists... Done Building dependency tree... Done Reading state information... Done 89 packages can be upgraded. Run 'apt list --upgradable' to see them
crontab -e
0 3 * * * /usr/local/bin/sync-ubuntu.sh