LXD 컨테이너로 Ubuntu 24.04에서 26.04 업그레이드 시험하기

운영 중인 서버를 Ubuntu 24.04에서 26.04로 바로 올린다고 하자. 그러면 패키지 제거나 설정 파일 충돌을 업그레이드 도중에 처음 만난다. 서버를 VM으로 복제해 시험하면 준비에 시간이 든다. LXD 컨테이너는 같은 Ubuntu 이미지를 몇 초 만에 띄우고, 스냅샷으로 업그레이드 전 상태로 바로 되돌린다. 이 글에서는 LXD 컨테이너에서 do-release-upgrade를 미리 실행해 보고, 결과를 확인하고 되돌리는 절차를 정리한다.

LXD 설치와 기본 명령은 LXD로 Ubuntu 컨테이너 사용하기를, Mac에서 LXD를 쓰는 방법은 맥(macOS)에서 Lima로 Ubuntu VM 사용하기를 참고한다.

시험용 24.04 컨테이너 준비

운영 서버와 같은 서비스를 설치한다. 여기서는 nginx 하나와 업그레이드 전 버전을 적은 페이지를 둔다.

$ lxc launch ubuntu:24.04 web24
$ lxc exec web24 -- cloud-init status --wait
status: done
$ lxc exec web24 -- sh -c "apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq nginx"
$ lxc exec web24 -- sh -c 'echo "<h1>hello from $(lsb_release -ds)</h1>" > /var/www/html/index.html'
$ lxc exec web24 -- curl -s localhost
<h1>hello from Ubuntu 24.04.5 LTS</h1>

업그레이드 전 준비

do-release-upgrade는 현재 릴리스의 패키지가 최신이어야 진행한다. 먼저 full-upgrade를 실행하고, 재시작이 필요하면 컨테이너를 재시작한다.

$ lxc exec web24 -- sh -c "DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y -qq"
$ lxc exec web24 -- ls /var/run/reboot-required
/var/run/reboot-required
$ lxc restart web24

-c는 업그레이드할 수 있는 새 릴리스가 있는지만 확인한다.

$ lxc exec web24 -- do-release-upgrade -c
Checking for a new Ubuntu release
New release '26.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
$ lxc exec web24 -- grep ^Prompt /etc/update-manager/release-upgrades
Prompt=lts

26.04.1이 나와서 LTS 간 업그레이드 경로가 열려 있으므로 -d가 필요 없다.

스냅샷 만들기

$ lxc snapshot web24 before-upgrade
$ lxc info web24 | sed -n '/^Snapshots/,$p'
Snapshots:
+----------------+----------------------+------------+----------+------------------+
|      NAME      |       TAKEN AT       | EXPIRES AT | STATEFUL | VOLUME SNAPSHOTS |
+----------------+----------------------+------------+----------+------------------+
| before-upgrade | 2026/11/26 01:21 KST |            | NO       |                  |
+----------------+----------------------+------------+----------+------------------+

업그레이드 실행

시험에서는 질문 없이 끝까지 진행하도록 비대화형 프런트엔드(DistUpgradeViewNonInteractive)를 쓴다.

$ time lxc exec web24 -- env DEBIAN_FRONTEND=noninteractive \
    do-release-upgrade -f DistUpgradeViewNonInteractive > upgrade.log 2>&1

real	7m40.184s
user	0m0.099s
sys	0m0.040s
$ wc -l upgrade.log
2867 upgrade.log
$ grep -A1 "reboot is required" upgrade.log
A reboot is required to replace the running dbus-daemon.
Please reboot the system when convenient.

업그레이드 도구의 자세한 로그는 컨테이너 안 /var/log/dist-upgrade/에 남는다.

파일내용
main.log업그레이드 단계, 소스 변경, 제거 대상(Obsolete) 계산
apt-term.log패키지 설치·제거 터미널 출력
history.logapt 트랜잭션별 시작·종료 시각

업그레이드 결과 확인

컨테이너를 재시작하고 부팅이 끝날 때까지 기다린 뒤 확인한다.

$ lxc restart web24
$ lxc exec web24 -- systemctl is-system-running --wait
degraded
$ lxc exec web24 -- grep PRETTY /etc/os-release
PRETTY_NAME="Ubuntu 26.04.1 LTS"
$ lxc exec web24 -- systemctl is-active nginx
active
$ lxc exec web24 -- nginx -v
nginx version: nginx/1.28.3 (Ubuntu)
$ lxc exec web24 -- curl -s localhost
<h1>hello from Ubuntu 24.04.5 LTS</h1>

nginx는 1.24.0에서 1.28.3으로 올라갔고, 웹 페이지 파일은 그대로 남았다. degraded의 원인은 실패한 유닛 목록으로 확인한다.

$ lxc exec web24 -- systemctl --failed --no-legend
● console-getty.service loaded failed failed Console Getty
$ lxc exec web24 -- journalctl -u console-getty -b --no-pager -n 6 | grep STDIN
Nov 25 16:29:34 web24 (agetty)[539]: console-getty.service: Failed at step STDIN spawning /usr/sbin/agetty: No such file or directory

새로 만든 ubuntu:26.04 컨테이너에서도 같은 유닛이 실패한다. 업그레이드 문제가 아니라 26.04 컨테이너 공통 현상이다.

$ lxc launch ubuntu:26.04 fresh26
$ lxc exec fresh26 -- systemctl --failed --no-legend
● console-getty.service loaded failed failed Console Getty

APT 소스와 설정 파일 변경도 확인한다. 업그레이드 도구는 소스의 코드네임을 resolute로 바꾼다. dpkg는 새 설정 파일을 설치하면 이전 파일을 .dpkg-old로 남긴다.

$ lxc exec web24 -- grep ^Suites /etc/apt/sources.list.d/ubuntu.sources
Suites: resolute resolute-updates resolute-backports
Suites: resolute-security
$ lxc exec web24 -- find /etc -name "*.dpkg-*" -o -name "*.ucf-*"
/etc/ca-certificates.conf.dpkg-old

제거된 패키지 확인

비대화형 모드는 26.04에 없는 패키지를 묻지 않고 제거한다. 라이브러리를 빼면 아래 패키지가 제거됐다.

분류제거된 패키지
도구byobu, pastebinit, pollinate, run-one, sosreport
네트워크networkd-dispatcher
Python 3.12python3.12, python3.12-minimal, python3-colorama, python3-newt
기타keyboxd, packagekit-tools, perl-modules-5.38, systemd-dev, gcc-14-base, gir1.2-girepository-2.0

새 26.04 컨테이너에도 이 패키지는 설치되어 있지 않다. 업그레이드한 컨테이너의 패키지 목록은 새 26.04 컨테이너와 같다.

$ lxc exec fresh26 -- dpkg -l byobu sosreport | tail -2
un  byobu          <none>       <none>       (no description available)
un  sosreport      <none>       <none>       (no description available)

운영 서버에서 이 도구를 스크립트로 쓰고 있다면 업그레이드 뒤에 다시 설치할지 정해 둔다.

업그레이드 전 상태로 되돌리기

$ time lxc restore web24 before-upgrade

real	0m3.691s
user	0m0.049s
sys	0m0.020s
$ lxc exec web24 -- grep PRETTY /etc/os-release
PRETTY_NAME="Ubuntu 24.04.5 LTS"
$ lxc exec web24 -- systemctl is-system-running --wait
running
$ lxc exec web24 -- curl -s localhost
<h1>hello from Ubuntu 24.04.5 LTS</h1>

업그레이드에 8분 가까이 걸렸지만 되돌리기는 4초 안에 끝난다. 설정을 바꿔 가며 업그레이드를 여러 번 반복할 수 있다.

확인 항목 정리

항목명령
릴리스 버전grep PRETTY /etc/os-release
부팅 완료·실패 유닛systemctl is-system-running --wait, systemctl --failed
서비스 동작systemctl is-active <서비스>, 실제 요청(curl)
APT 소스grep ^Suites /etc/apt/sources.list.d/*.sources
설정 파일 충돌find /etc -name "*.dpkg-*" -o -name "*.ucf-*"
제거된 패키지grep ^Removing /var/log/dist-upgrade/apt-term.log

실제 서버 업그레이드 절차(SSH 1022 포트, 재부팅 확인)는 Ubuntu 24.04에서 26.04로 업그레이드 방법에 정리했다.

주의사항

  • 재시작 직후에 서비스 상태를 판단하지 말 것. 부팅이 끝나기 전에는 정상 서비스도 inactive로 보인다. systemctl is-system-running --wait로 부팅 완료를 먼저 기다린다.
  • 컨테이너 결과로 커널 업그레이드를 판단하지 말 것. 컨테이너는 호스트 커널을 쓰므로 linux-image 교체, 부트로더, 커널 모듈 문제는 이 방법으로 확인할 수 없다.
  • 운영 서버에서는 비대화형 프런트엔드를 그대로 쓰지 말 것. 패키지 제거와 설정 파일 선택을 묻지 않고 진행한다. 시험에서 결과를 확인한 뒤, 실제 서버는 대화형 do-release-upgrade로 진행한다.
  • 컨테이너를 운영 서버와 같다고 가정하지 말 것. PPA와 서드파티 저장소, 직접 수정한 설정 파일까지 운영 서버와 맞춰야 시험 결과가 의미가 있다. do-release-upgrade는 서드파티 소스를 업그레이드 중에 비활성화한다.
  • 스토리지 풀 드라이버가 dir이면 스냅샷이 루트 파일 시스템 전체를 복사한다. 디스크 여유 공간을 확인하고 시험이 끝나면 스냅샷이나 컨테이너를 지운다.

마무리

LXD 컨테이너에서 24.04를 26.04.1로 올리는 데 8분 가까이 걸렸고, 스냅샷으로 4초 안에 되돌렸다. 제거되는 패키지와 설정 파일 변경을 미리 확인해 두면 실제 서버 업그레이드에서 판단할 일이 줄어든다.

참고

답글 남기기