こんな感じでpv丸ごとコピーした場合。
PVのuuidが同じになるのでエラーとなってしまう。
dd if=/dev/xvda2 of=/dev/xvdb2
# pvs WARNING: Not using lvmetad because duplicate PVs were found. WARNING: Use multipath or vgimportclone to resolve duplicate PVs? WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad. WARNING: PV 0yTzZw-rtCB-XEqN-rXsR-H9x1-BsJF-rySufQ on /dev/xvdb2 was already found on /dev/xvda2. WARNING: PV 0yTzZw-rtCB-XEqN-rXsR-H9x1-BsJF-rySufQ prefers device /dev/xvda2 because device is used by LV. PV VG Fmt Attr PSize PFree /dev/xvda2 centos lvm2 a-- 19.51g 40.00m
vgimportclone でuuidを変更してあげると、治ります。
LVをマウントしたままだと実行できない。
# vgimportclone /dev/xvda1 WARNING: PV 0yTzZw-rtCB-XEqN-rXsR-H9x1-BsJF-rySufQ on /dev/xvdb2 was already found on /dev/xvda2. WARNING: PV 0yTzZw-rtCB-XEqN-rXsR-H9x1-BsJF-rySufQ prefers device /dev/xvda2 because device is used by LV. Failed to find physical volume "/dev/xvda1". Failed to find all devices. WARNING: PV 0yTzZw-rtCB-XEqN-rXsR-H9x1-BsJF-rySufQ on /dev/xvdb2 was already found on /dev/xvda2.
アンマウント、もしくはrootディスクの場合リカバリーモードで起動後に実行してあげる。
# vgimportclone /dev/xvda2 WARNING: PV 0yTzZw-rtCB-XEqN-rXsR-H9x1-BsJF-rySufQ on /dev/xvdb2 was already found on /dev/xvda2. WARNING: PV 0yTzZw-rtCB-XEqN-rXsR-H9x1-BsJF-rySufQ prefers device /dev/xvda2 because device is used by LV. Device /dev/xvda2 has active LVs, deactivate first. WARNING: PV 0yTzZw-rtCB-XEqN-rXsR-H9x1-BsJF-rySufQ on /dev/xvdb2 was already found on /dev/xvda2. WARNING: Disabling lvmetad cache which does not support duplicate PVs.