문서의 이전 판입니다!


PVE9 local repository 구성

인터넷이 안되는 환경이나 특수한 상황에서 PVE를 구성해야 할 경우 레포지토리를 접근하기 위해 로컬에 레포지토리 미러를 구성하는 방법에 대해 설명한다.

먼저 인터넷환경의 pve9 서버를 하나 설치한다. 그리고 레포지토리 미러링을 위한 디스크를 추가로 구성하도록 한다.
기본 디스크는 OS와 local storage로 등록되기 때문에 추가 디스크를 할당하는것이 좋다.

로컬 미러를 구성할 경로를 /repo라고 가정한다.

먼저 미러를 위한 proxmox-offline-mirror 툴을 설치한다.

$ apt install proxmox-offline-mirror

이후 미러를 하기 위한 설정을 진행한다.

proxmox-repo:~# proxmox-offline-mirror setup
Loaded existing config.

Existing config entries:
mirror 'pve_trixie_no-subscription'
mirror 'debian_trixie_security'
mirror 'debian_trixie_main'
mirror 'debian_trixie_updates'
mirror 'ceph_squid_trixie'

Select Action:
   0) Add new mirror entry
   1) Add new medium entry
   2) Add new subscription key
   3) Quit

Add new mirror entry 로 미러할 레포지토리를 선택한다. mediumsubscription은 없으므로 생략한다.

  • pve_trixie_no-subscription
  • debian_trixie_security
  • debian_trixie_main
  • debian_trixie_updates
  • ceph_squid_trixie

위의 5개 레포지토리를 선택했다면 저장하고 나와서 스냅샷을 생성하고 미러링을 수행한다.

# 스냅샷 생성 및 미러링 시작
$ proxmox-offline-mirror mirror snapshot create <MIRROR_NAME>

# 미러링 완료 후 정리
$ proxmox-offline-mirror mirror gc

하지만 미러링이 동작하게 되면 오랜시간이 걸리거나 중간에 오류로 중단되거나 할 경우가 있는데 일일히 명령어를 재시도 하기보단 아래 스크립트를 이용하도록 한다.

mirror.sh

#!/bin/bash
# 미러 ID 목록
MIRRORS=(
  pve_trixie_no-subscription
  ceph_squid_trixie
  debian_trixie_main
  debian_trixie_security
  debian_trixie_updates
)

# 각 미러에 대해 스냅샷 생성
for MIRROR in "${MIRRORS[@]}"; do
  echo "Creating snapshot for $MIRROR..."
  proxmox-offline-mirror mirror snapshot create "$MIRROR"
  if [ $? -eq 0 ]; then
    echo "Snapshot for $MIRROR created successfully."
  else
    echo "Error creating snapshot for $MIRROR."
  fi
done

# 가비지 컬렉션 실행
echo "Running garbage collection..."
proxmox-offline-mirror mirror gc
echo "Garbage collection completed."

로컬 미러를 동기화 완료하면 아래와 같은 디렉토리 구성이 보이게 된다.

proxmox-repo:~# cd /var/lib/proxmox-offline-mirror/mirrors/
proxmox-repo:/var/lib/proxmox-offline-mirror/mirrors# ll
total 32
drwxr-xr-x 8 root root 4096 Oct 16 10:31 ./
drwxr-xr-x 3 root root 4096 Oct 16 10:30 ../
drwxr-xr-x 7 root root 4096 Oct 16 15:12 ceph_squid_trixie/
drwxr-xr-x 7 root root 4096 Oct 16 15:16 debian_trixie_main/
drwxr-xr-x 8 root root 4096 Oct 16 15:16 debian_trixie_security/
drwxr-xr-x 7 root root 4096 Oct 16 15:16 debian_trixie_updates/
drwxr-xr-x 4 root root 4096 Oct 16 10:31 .pool/
drwxr-xr-x 7 root root 4096 Oct 16 15:12 pve_trixie_no-subscription/
proxmox-repo:/var/lib/proxmox-offline-mirror/mirrors# tree -L 3
.
├── ceph_squid_trixie
│   ├── 2025-10-16T01:52:19Z
│   │   └── dists
│   ├── 2025-10-16T02:13:46Z
│   │   └── dists
│   ├── 2025-10-16T03:01:59Z
│   │   └── dists
│   ├── 2025-10-16T04:40:44Z
│   │   └── dists
│   └── 2025-10-16T06:12:13Z
│       └── dists
├── debian_trixie_main
│   ├── 2025-10-16T01:54:37Z.tmp
│   │   ├── dists
│   │   └── pool
│   ├── 2025-10-16T02:13:47Z.tmp
│   │   ├── dists
│   │   └── pool
│   ├── 2025-10-16T03:02:02Z.tmp
│   │   ├── dists
│   │   └── pool
│   ├── 2025-10-16T04:40:47Z
│   │   ├── dists
│   │   └── pool
│   └── 2025-10-16T06:12:16Z
│       ├── dists
│       └── pool
├── debian_trixie_security
│   ├── 2025-10-16T01:31:59Z
│   │   ├── dists
│   │   └── pool
│   ├── 2025-10-16T01:58:16Z
│   │   ├── dists
│   │   └── pool
│   ├── 2025-10-16T02:22:15Z
│   │   ├── dists
│   │   └── pool
│   ├── 2025-10-16T04:38:51Z
│   │   ├── dists
│   │   └── pool
│   ├── 2025-10-16T06:11:35Z
│   │   ├── dists
│   │   └── pool
│   └── 2025-10-16T06:16:05Z
│       ├── dists
│       └── pool
├── debian_trixie_updates
│   ├── 2025-10-16T01:58:29Z
│   │   ├── dists
│   │   └── pool
│   ├── 2025-10-16T02:22:28Z
│   │   ├── dists
│   │   └── pool
│   ├── 2025-10-16T04:39:05Z
│   │   ├── dists
│   │   └── pool
│   ├── 2025-10-16T06:11:50Z
│   │   ├── dists
│   │   └── pool
│   └── 2025-10-16T06:16:20Z
│       ├── dists
│       └── pool
└── pve_trixie_no-subscription
    ├── 2025-10-16T01:40:20Z.tmp
    │   └── dists
    ├── 2025-10-16T02:04:53Z
    │   └── dists
    ├── 2025-10-16T03:01:43Z
    │   └── dists
    ├── 2025-10-16T04:40:27Z
    │   └── dists
    └── 2025-10-16T06:11:55Z
        └── dists

74 directories, 0 files

위와같이 미러링을 시도할때마다 스냅샷이 날짜시간 형태로 계속해서 만들어진다. 그렇다고 해서 동일한 패키지 파일을 계속 받아두는 방식은 아니고 .pool 디렉토리에 패키지 원본파일이 저장되어있고 스냅샷 디렉토리에는 하드링크로 존재하는 형태로 구성된다.

이렇게 미러는 구성되어 있지만 우리는 일반적인 레포지토리 형태로 사용하고 싶기 때문에 아래 스크립트를 이용하여 레포지토리를 복제하도록 한다.

copy-mirror.sh

#!/bin/bash
MIRROR_BASE=/repo
ORIG_BASE=/var/lib/proxmox-offline-mirror/mirrors
for MIRROR in ceph_squid_trixie debian_trixie_main debian_trixie_security debian_trixie_updates pve_trixie_no-subscription; do
  LATEST=$(ls -d $ORIG_BASE/$MIRROR/*Z | sort -r | head -n 1)
  echo "LATEST=$LATEST"
  if [ -n "$LATEST" ]; then
    rm -rf $MIRROR_BASE/$MIRROR/
    rsync -a --copy-links $LATEST/ $MIRROR_BASE/$MIRROR/
    echo "Converted $MIRROR to actual files from $LATEST."
  fi
done

위 코드는 스냅샷형태로 되어있는 레포지토리를 일반적인 디렉토리 형태로 복제하는 스크립트이다. 예제에서는 /repo 디렉토리에 복사하도록 되어있다.

위 스크립트를 실행하게 되면 /repo 디렉토리에 아래와 같이 최신 스냅샷 기준으로 레포지토리가 복제된다.

proxmox-repo:~# cd /repo/
proxmox-repo:/repo# ls -al
total 28
drwxr-xr-x  7 root root 4096 Oct 17 12:18 ./
drwxr-xr-x 19 root root 4096 Oct 16 15:17 ../
drwxr-xr-x  3 root root 4096 Oct 16 15:12 ceph_squid_trixie/
drwxr-xr-x  4 root root 4096 Oct 16 15:12 debian_trixie_main/
drwxr-xr-x  4 root root 4096 Oct 16 15:16 debian_trixie_security/
drwxr-xr-x  4 root root 4096 Oct 16 15:16 debian_trixie_updates/
drwxr-xr-x  3 root root 4096 Oct 16 15:11 pve_trixie_no-subscription/
proxmox-repo:/repo# tree -L3
.
├── ceph_squid_trixie
│   └── dists
│       └── trixie
├── debian_trixie_main
│   ├── dists
│   │   └── trixie
│   └── pool
│       ├── contrib
│       └── main
├── debian_trixie_security
│   ├── dists
│   │   └── trixie-security
│   └── pool
│       └── updates
├── debian_trixie_updates
│   ├── dists
│   │   └── trixie-updates
│   └── pool
│       └── main
└── pve_trixie_no-subscription
    └── dists
        └── trixie

23 directories, 0 files

위와같이 최종적으로 만들어진 레포지토리를 다른 서버에서 사용하기 위해 레포지토리 소스를 아래처럼 등록한다.

local.sources 파일 형태로 사용할 경우

#####
# PVE9 local repository sources type
# 2025-10-16
#####
Types: deb
URIs: file:///repo/ceph_squid_trixie
Suites: trixie
Components: no-subscription
Trusted: yes

Types: deb
URIs: file:///repo/debian_trixie_main
Suites: trixie
Components: main contrib
Trusted: yes

Types: deb
URIs: file:///repo/debian_trixie_security
Suites: trixie-security
Components: main
Trusted: yes

Types: deb
URIs: file:///repo/debian_trixie_updates
Suites: trixie-updates
Components: main
Trusted: yes

Types: deb
URIs: file:///repo/pve_trixie_no-subscription
Suites: trixie
Components: pve-no-subscription
Trusted: yes

local.list 형태로 사용할 경우

#####
# PVE9 local repository list type
# 2025-10-16
#####
deb [trusted=yes] file:///repo/ceph_squid_trixie trixie no-subscription
deb [trusted=yes] file:///repo/debian_trixie_main trixie main contrib
deb [trusted=yes] file:///repo/debian_trixie_security trixie-security main
deb [trusted=yes] file:///repo/debian_trixie_updates trixie-updates main
deb [trusted=yes] file:///repo/pve_trixie_no-subscription trixie pve-no-subscription
  • pve9_local_repository_구성.1760673722.txt.gz
  • 마지막으로 수정됨: 2025/10/17 04:02
  • 저자 koov