I'm running Arch Linux. I want to clone a 2 disk encrypted logical volume in a single volume group (LUKS on LVM). There is a slight catch. I want to swap some of the drives.
- VG1: LV: PV(OldDrive1) + PV(OldDrive2)
sda (OldDrive1) -vg1-luks_encrypted_lv sdb (OldDrive2) -vg1-luks_encrypted_lv
I have two other drives (NewDrive1 and NewDrive2). I want to create a VG2 that is a clone of VG1. However, I want to swap some drives around. So I want:
- VG1: LV: PV(OldDrive1) + PV(NewDrive1)
- VG2: LV: PV(OldDrive2) + PV(NewDrive2)
sda (OldDrive1) -vg1-luks_encrypted_lv sdb (OldDrive2) -vg2-cloned_luks_encrypted_lv sdc (NewDrive1) -vg1-luks_encrypted_lv sdd (NewDrive2) -vg2-cloned_luks_encrypted_lv
My current plan is to clone each drive. I was previously thinking about using dd, but after some reading maybe I need to use pvmove?:
- OldDrive1 -> NewDrive1
- OldDrive2 -> NewDrive2
Could I then just swap the physical drives in LVM, because the drives are bit-by-bit clones? I'm worried I'm missing something. How would I incorporate the news drives into the LV? I would appreciate some advice, because I don't want to lose any data. Thanks.
@telcoM 's answer worked very well. Thank you very much. I used the on-line method. If anyone wants to do something similar there are few things worth noting.
On Step 7:
lvconvert -m default is now raid1, not lvm's own mirror system. Read
man lvconvert for more details. Since I wanted to immediately split the mirror, it was much easier to just use the lvm's legacy mirror with the mirrorlog stored in memory:
lvconvert --type mirror -m +1 --mirrorlog core vg1/luks_encrypted_lv OldDrive2 NewDrive2
Just remember that
--mirrorlog core puts the mirrorlog in memory. So don't turn off your computer before running
lvconvert --splitmirrors or you will lose your mirrorlog file.
On Step 9:
Before you do
vgsplit you need to unmount the filesystem and deactivate the logical volume.
On Step 11:
Most people probably realize this, but you need to assign a UUID to
$uuid before you run
cryptsetup luksUUID --uuid $(uuid) /dev/mapper/VG2-LVx. Run something like