![Linux LVM - 创建镜像、破坏它、将其中一个部分带到另一个系统并在那里使用它](https://linux22.com/image/786194/Linux%20LVM%20-%20%E5%88%9B%E5%BB%BA%E9%95%9C%E5%83%8F%E3%80%81%E7%A0%B4%E5%9D%8F%E5%AE%83%E3%80%81%E5%B0%86%E5%85%B6%E4%B8%AD%E4%B8%80%E4%B8%AA%E9%83%A8%E5%88%86%E5%B8%A6%E5%88%B0%E5%8F%A6%E4%B8%80%E4%B8%AA%E7%B3%BB%E7%BB%9F%E5%B9%B6%E5%9C%A8%E9%82%A3%E9%87%8C%E4%BD%BF%E7%94%A8%E5%AE%83.png)
使用 LVM,我想要创建一个 LV 的镜像,同步它,将其断开,将镜像附加到不同的系统,并在那里使用它。
从普通的线性 LV 开始。以下是我的程序:
#### 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
这是安全克隆磁盘/LV 并在其他地方重复使用的正确步骤吗?原始主机系统上是否应该进行其他 LVM 清理?
提前致谢。