Using LVM, I would like to create a mirror of a LV, sync it, break it off, attach the mirror-piece to a different system, use it there.
Start with a ordinary linear LV. Here is the procedure I have:
#### create a mirror
## variables
OLDPV=/dev/sdf
NEWPV=/dev/sdj
VG=somevg
OLDLV=data
NEWLV=mirr
## add storage to machine, put it under LVM control, add to $VG
pvcreate -vy $NEWPV
vgextend -vy $VG $NEWPV
## create a mirror
lvcreate -vy --type raid1 -m1 -L $SIZE -n $OLDLV $VG
## previous lvcreate should select the empty PV we just added
## use "lvs -v" to monitor progress of mirror synchronization (Cpy%Sync)
lvs -v
## Once the sync is 100# -- split the mirror
## Question: do I need to umount LV?
lvconvert -vy --splitmirrors 1 --name $NEWLV $VG/$OLDLV $NEWPV
## convert source vol back to 'linear'
lvconvert -vy --type linear -n $OLDLV $VG
## pull $NEWPV out of $VG (put it in 'temp' - assumes no temp already exists)
vgsplit -vy $VG temp $NEWPV
## disassociate temp VG
vgchange -vy --activate n temp
## safely remove $NEWPV from instance
vgremove -vy temp
## attach mirrored LV to a separate machine
vgscan
vgmerge -yv temp $LOCALVG
Is this the correct set of steps to safely clone a disk/LV and reuse it elsewhere? Is there additional LVM clean up that should happen on the original host system?
Thanks in advance.