Skip to Content

롤백 전략

Ubuntu의 do-release-upgrade은 기본 다운그레이드를 지원하지 않습니다. 업그레이드 후 심각한 문제가 발생하는 경우 사전에 준비된 롤백 계획을 활용해야 합니다. 이 문서에서는 몇 가지 실용적인 롤백 전략을 다룹니다.

롤백 옵션 비교

옵션복구 속도준비의 복잡성사용 사례
타임시프트빠르게(분)낮음데스크탑 및 소형 서버
LVM 스냅샷빠르게(분)중간LVM을 사용하는 시스템
Btrfs 스냅샷매우 빠르다중간Btrfs 파일 시스템
dd 디스크 이미지느림(디스크 크기에 따라 다름)낮음범용 옵션
백업 복원 + 재설치느림높음최후의 수단
클라우드 플랫폼 스냅샷빠르게낮음클라우드 서버

타임시프트 스냅샷 복원

Timeshift는 RSYNC 및 Btrfs 모드를 모두 지원하는 가장 사용자 친화적인 시스템 스냅샷 도구입니다.

업그레이드 전 스냅샷 생성

# Install Timeshift sudo apt install timeshift -y # Create a snapshot sudo timeshift --create --comments "Pre-upgrade backup" --tags D # List snapshots sudo timeshift --list

스냅샷에서 복원

방법 1: 시스템이 아직 부팅 가능함

# List available snapshots sudo timeshift --list # Restore a specific snapshot sudo timeshift --restore --snapshot "2026-03-24_10-00-00" # You will be prompted to confirm; choose what to restore # Reboot after restoration is complete sudo reboot

방법 2: 시스템을 부팅할 수 없음

  1. Ubuntu Live USB에서 부팅
  2. 라이브 환경에서 Timeshift를 설치하고 실행합니다.
# In the live environment sudo apt update sudo apt install timeshift -y # Timeshift will automatically detect snapshots on disk sudo timeshift --list # Restore a snapshot sudo timeshift --restore --snapshot "2026-03-24_10-00-00" sudo reboot

타임시프트 노트

  • Timeshift는 기본적으로(RSYNC 모드에서) /home을 백업하지 않습니다. 사용자 데이터는 별도로 백업해야 함
  • 스냅샷에는 충분한 디스크 공간이 필요합니다.
  • RSYNC 모드 스냅샷은 시간이 지남에 따라 크기가 증가합니다(증분)
  • Btrfs 모드는 더 효율적이지만 Btrfs 파일 시스템이 필요합니다.

LVM 스냅샷 롤백

시스템이 LVM(Ubuntu Server 설치 중 기본 옵션)을 사용하는 경우 빠른 롤백을 위해 LVM 스냅샷을 사용할 수 있습니다.

업그레이드 전 LVM 스냅샷 생성

# View existing logical volumes sudo lvs sudo vgs # Confirm the volume group has enough free space # Create a snapshot for the root partition (requires free space in the volume group) sudo lvcreate -L 10G -s -n root-snap /dev/ubuntu-vg/ubuntu-lv # If there is a separate /var partition sudo lvcreate -L 5G -s -n var-snap /dev/ubuntu-vg/var-lv # Verify the snapshot sudo lvs

LVM 스냅샷에서 롤백

# Method 1: Merge the snapshot (requires unmounting or operating from Live USB) # If you can still access the system # Mark the snapshot for merge (takes effect on next activation) sudo lvconvert --merge /dev/ubuntu-vg/root-snap # The merge will execute automatically after reboot sudo reboot # Method 2: Operate from Live USB # Boot from Live USB sudo apt install lvm2 -y sudo vgchange -ay # Activate volume groups # Execute the merge sudo lvconvert --merge /dev/ubuntu-vg/root-snap sudo reboot

여유 공간이 없는 경우

# View current LVM usage sudo vgs # If VFree is 0, you can shrink an existing logical volume (dangerous, proceed with caution) # Shrink the filesystem first, then shrink the logical volume # Recommended to do this from a Live USB # Check the filesystem sudo e2fsck -f /dev/ubuntu-vg/ubuntu-lv # Shrink the filesystem to 15G sudo resize2fs /dev/ubuntu-vg/ubuntu-lv 15G # Shrink the logical volume to 16G (leave some headroom) sudo lvreduce -L 16G /dev/ubuntu-vg/ubuntu-lv # Now there is space to create a snapshot sudo lvcreate -L 10G -s -n root-snap /dev/ubuntu-vg/ubuntu-lv

Btrfs 스냅샷 롤백

Btrfs 파일 시스템을 사용하는 경우 스냅샷 작업은 거의 즉각적으로 수행됩니다.

Btrfs 스냅샷 만들기

# View Btrfs subvolumes sudo btrfs subvolume list / # Create a read-only snapshot sudo btrfs subvolume snapshot -r / /snapshots/pre-upgrade-$(date +%Y%m%d) # List snapshots sudo btrfs subvolume list / | grep snapshot

Btrfs 스냅샷에서 복원

# Boot from Live USB # Mount the Btrfs partition sudo mount /dev/sda2 /mnt # View subvolumes sudo btrfs subvolume list /mnt # Rename the current root subvolume sudo mv /mnt/@ /mnt/@broken # Create a new root subvolume from the snapshot sudo btrfs subvolume snapshot /mnt/snapshots/pre-upgrade-20260324 /mnt/@ # Reboot sudo reboot

dd 디스크 이미지 복구

가장 간단하지만 가장 보편적인 접근 방식은 모든 파일 시스템에서 작동합니다.

디스크 이미지 생성

# Recommended to create from Live USB to ensure partitions are unmounted # Full disk image sudo dd if=/dev/sda of=/mnt/external/full-disk.img bs=4M status=progress # Compressed image sudo dd if=/dev/sda bs=4M status=progress | gzip > /mnt/external/full-disk.img.gz # Back up a specific partition only sudo dd if=/dev/sda2 of=/mnt/external/root-partition.img bs=4M status=progress

dd 이미지에서 복원

# Boot from Live USB # Restore the full disk sudo dd if=/mnt/external/full-disk.img of=/dev/sda bs=4M status=progress # Restore a compressed image gunzip -c /mnt/external/full-disk.img.gz | sudo dd of=/dev/sda bs=4M status=progress # Restore a single partition sudo dd if=/mnt/external/root-partition.img of=/dev/sda2 bs=4M status=progress # Update GRUB after restoration sudo mount /dev/sda2 /mnt sudo mount /dev/sda1 /mnt/boot/efi sudo mount --bind /dev /mnt/dev sudo mount --bind /proc /mnt/proc sudo mount --bind /sys /mnt/sys sudo chroot /mnt grub-install /dev/sda update-grub exit sudo reboot

클라우드 서버 스냅샷 복구

다양한 클라우드 플랫폼 운영

# Alibaba Cloud - create a snapshot using CLI aliyun ecs CreateSnapshot --DiskId d-xxx --SnapshotName pre-upgrade # Tencent Cloud tccli cbs CreateSnapshot --cli-input-json '{"DiskId":"disk-xxx","SnapshotName":"pre-upgrade"}' # AWS aws ec2 create-snapshot --volume-id vol-xxx --description "pre-upgrade" # To restore: use "Roll Back Disk" or "Create Disk from Snapshot" in each platform's console

부분 롤백: 업그레이드 문제 해결

전체 롤백이 필요하지 않은 경우도 있습니다. 특정 문제를 해결하는 것으로 충분할 수 있습니다.

손상된 패키지 수정

# Configure unconfigured packages sudo dpkg --configure -a # Fix dependencies sudo apt --fix-broken install # Reinstall a problematic package sudo apt install --reinstall package-name # Force reinstall sudo dpkg -i --force-overwrite /var/cache/apt/archives/package-name*.deb

이전 커널로 부팅하기

# Select "Advanced options for Ubuntu" from the GRUB menu # Choose an older kernel version to boot # If the GRUB menu doesn't appear (countdown too short) # Hold Shift during boot (BIOS) or press Esc (UEFI) # After entering the system, fix kernel issues sudo apt install --reinstall linux-image-$(uname -r) sudo update-grub

복구 모드

# Select Recovery Mode from GRUB # Available options: # - dpkg fix broken packages # - fsck check filesystem # - network enable networking # - root enter root shell # In the root shell mount -o remount,rw / apt --fix-broken install dpkg --configure -a reboot

예방 조치 요약

업그레이드 전 준비에 따라 롤백 가능성이 직접 결정됩니다.

  1. 반드시 해야 할 일: 전체 데이터 백업(데이터베이스, 구성, 사용자 파일)
  2. 적극 권장: 시스템 스냅샷(Timeshift, LVM, Btrfs)
  3. 클라우드 서버: 디스크 스냅샷 만들기
  4. 가상 머신: VM 스냅샷 만들기
  5. 중요 시스템: 검증을 위해 먼저 테스트 환경에서 업그레이드하세요.

롤백 결정 흐름

Issue found after upgrade |-- Is the issue fixable? | |-- Yes -> Fix the specific issue (package repair, config adjustment) | +-- No -> Continue assessment | |-- Is there a system snapshot? | |-- Yes -> Restore snapshot (Timeshift/LVM/Btrfs) | +-- No -> Continue assessment | |-- Is there a disk image? | |-- Yes -> dd restore | +-- No -> Continue assessment | +-- Last resort +-- Reinstall system + restore data and configs from backup

가장 중요한 사항: 업그레이드하기 전에 항상 백업하십시오. 롤백에만 의존하지 마십시오.