Need to clone Proxmox install from unencrypted drive to drive with encrypted partition 3

dmpm

Member
Dec 29, 2023
79
3
8
Because the Proxmox installer doesn't allow for installing on an encrypted partition, we have to do a normal install and then copy it across to the encrypted drive, as explained here https://forum.proxmox.com/threads/adding-full-disk-encryption-to-proxmox.137051/ but that's a very laborious process.

I've found that I can use dd to copy across the EFI and Boot partitions (p1 and p2), and use lvcreate to make a snapshot of the root partition, which is a LV on p3, and then dd the snapshot onto the new drive inside the unlocked encrypted p3, but we can't make snapshots of thin-pools or thin-volumes, so I'm looking for a way to copy those across, as even with PBS backups it's very slow and tedious having to manually restore all the VMs and LXCs one by one.

I assume it's not possible to use Clonezilla to copy p3, because that will just replace the encrypted p3 on the second drive with the unencrypted p3 from the first drive. Is there any other way I can boot into something, unlock the encrypted partition and then copy across the data, volumes, etc. from the unencrypted p3 to the encrypted p3 without wiping it and losing the encryption?
 
I've used this script https://github.com/kneutron/ansitest/blob/master/proxmox/proxmox-migrate-disk-storage.sh to copy the LXC and VM disks to the encrypted data thinpool on the new drive (currently named pve-new/data).

However, that updates the conf files to point to the disks on pve-new, and on the new drive the /etc/pve folder is empty, so I presume I need to copy across all the files from that folder on the old drive, but I want to rename the VG from pve-new back to PVE-AM after I disconnect the old drive, so I guess I'll need to edit all the conf files to refer to that?

Is there a simpler/more automated way to do this, or a guide which shows the best way to copy a PVE install to a new drive which minimises the amount of renaming VGs/LVs and editing files?