You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu LUKS LVM架构系统分区信息备份恢复方法及扩容前备份方案咨询

Ubuntu LUKS LVM架构系统分区信息备份恢复方法及扩容前备份方案咨询

Hey friend, let's break down your situation and figure out the best backup approach before you expand your LUKS+LVM setup. First, let's recap your current disk layout to make sure we're on the same page:

nvme0n1                       259:0    0 223.6G  0 disk
├─nvme0n1p1                   259:1    0   487M  0 part  /boot
├─nvme0n1p2                   259:2    0     1K  0 part
└─nvme0n1p5                   259:3    0 118.8G  0 part
  └─sdb5_crypt                253:0    0 118.8G  0 crypt
    ├─ubuntu--nvme--vg-root   253:1    0 110.8G  0 lvm   /
    └─ubuntu--nvme--vg-swap_1 253:2    0     8G  0 lvm
      └─cryptswap1            253:3    0     8G  0 crypt [SWAP]

You mentioned you've been using a live USB to take backups by unmounting the drive—smart move, since working on a mounted filesystem can lead to corruption. Let's cover solid backup strategies tailored to your encrypted LVM setup, plus key checks before you start the expansion:

Backup Options to Consider

  • Full Disk Image (Most Reliable)
    Boot from your Ubuntu live USB, make sure the target drive (nvme0n1) is unmounted. Use dd or partclone to create a full image of the entire disk. For example:

    # Using dd (slow but straightforward)
    sudo dd if=/dev/nvme0n1 of=/path/to/external/drive/ubuntu_backup.img bs=4M status=progress
    

    Or partclone which is faster for used blocks:

    sudo partclone.dev -c -s /dev/nvme0n1 -o /path/to/external/drive/ubuntu_backup.img
    

    Pro tip: Compress the image to save space—pipe it through gzip:

    sudo dd if=/dev/nvme0n1 bs=4M status=progress | gzip > /path/to/external/drive/ubuntu_backup.img.gz
    
  • LUKS Container Backup
    Since your root filesystem is inside a LUKS container, you can back up just the encrypted partition instead of the whole disk. Unlock the container first (from live USB):

    sudo cryptsetup luksOpen /dev/nvme0n1p5 sdb5_crypt
    

    Then back up the LUKS header separately—this is critical! If the header gets corrupted, you'll lose access to your data:

    sudo cryptsetup luksHeaderBackup /dev/nvme0n1p5 --header-backup-file /path/to/external/drive/luks_header_backup.img
    

    After that, you can back up the unlocked LVM volume group with dd or create a snapshot with lvcreate if you prefer incremental backups later.

  • File-Level Backup
    If you don't want to deal with disk images, use rsync to copy all your files to an external drive. From the live USB, mount your root filesystem first:

    sudo cryptsetup luksOpen /dev/nvme0n1p5 sdb5_crypt
    sudo vgchange -ay ubuntu--nvme--vg
    sudo mount /dev/mapper/ubuntu--nvme--vg-root /mnt
    sudo rsync -aAXv /mnt/ /path/to/external/drive/backup/ --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"}
    

    This preserves permissions, symlinks, and extended attributes—great for restoring individual files if needed.

Pre-Expansion Checks

Before you start resizing, make sure:

  • Your external backup is verified—try mounting the image or checking the rsync backup to confirm all files are present.
  • You have the LUKS passphrase handy (obviously, but easy to overlook!).
  • The live USB you're using is the same Ubuntu version (20.04) as your installed system to avoid compatibility issues with LVM/LUKS tools.
  • Run sudo fdisk -l from the live USB to confirm the unallocated space is available on /dev/nvme0n1 after the existing partitions.

Once your backup is solid, you can proceed with expanding the partition, LUKS container, and LVM volume. But always prioritize that backup first—resizing encrypted volumes can go wrong if interrupted!

备注:内容来源于stack exchange,提问作者localhost

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 15:23:15