39、逻辑卷常见问题
一、pv 找不到
WARNING: VG vg1 is missing PV WARNING: Couldn't find device with uuid QiabIM-sK6k-Zqiy-dm2v-70FO-7aCo-I9rOzP.WARNING: VG vg1 is missing PV QiabIM-sK6k-Zqiy-dm2v-70FO-7aCo-I9rOzP (last written to [unknown]).Cannot change VG vg1 while PVs are missing.See vgreduce --removemissing and vgextend --restoremissing.Cannot process volume group vg1
解决办法:
[root@rhel8 ~]# vgreduce --removemissing --force vg1WARNING: Couldn't find device with uuid QiabIM-sK6k-Zqiy-dm2v-70FO-7aCo-I9rOzP.WARNING: VG vg1 is missing PV QiabIM-sK6k-Zqiy-dm2v-70FO-7aCo-I9rOzP (last written to [unknown]).WARNING: Couldn't find device with uuid QiabIM-sK6k-Zqiy-dm2v-70FO-7aCo-I9rOzP.Wrote out consistent volume group vg1.
[root@rhel8 ~]# vgscan --partialFound volume group "vg1" using metadata type lvm2Found volume group "rhel" using metadata type lvm2
[root@rhel8 ~]# lvscan --partialACTIVE '/dev/vg1/lv1' [1.50 GiB] inheritACTIVE '/dev/vg1/lv2' [200.00 MiB] inheritACTIVE '/dev/vg1/lv3' [1.14 GiB] inheritACTIVE '/dev/rhel/swap' [<2.03 GiB] inheritACTIVE '/dev/rhel/root' [<26.97 GiB] inherit二、LVM 中 PV 出现了坏道
案例:vg1 中 sdb4 出现坏道,将 sdb4 数据拷贝到 sdb8
停用逻辑卷 lv1
[root@rhel8 ~]# umount /lv1
[root@rhel8 ~]# lvchange -an /dev/vg1/lv1移动 数据
[root@rhel8 ~]# pvmove /dev/sdb4 /dev/sdb8/dev/sdb4: Moved: 26.67%/dev/sdb4: Moved: 100.00%停用 卷组 vg1
[root@rhel8 ~]# vgchange -a n /dev/vg1Logical volume vg1/lv3 contains a filesystem in use.Can't deactivate volume group "vg1" with 2 open logical volume(s)
[root@rhel8 ~]# umount /lv3
[root@rhel8 ~]# vgchange -a n /dev/vg1Logical volume vg1/swap in use.Can't deactivate volume group "vg1" with 1 open logical volume(s)
[root@rhel8 ~]# swapoff /dev/vg1/swap
[root@rhel8 ~]# vgchange -a n /dev/vg10 logical volume(s) in volume group "vg1" now active移除损坏的设备 /dev/sdb4
[root@rhel8 ~]# vgreduce vg1 /dev/sdb4Removed "/dev/sdb4" from volume group "vg1"使用 卷组 vg1
[root@rhel8 ~]# vgchange -a y /dev/vg14 logical volume(s) in volume group "vg1" now active使用 逻辑卷 lv1
[root@rhel8 ~]# lvchange -a y /dev/vg1/lv1卷组迁移:
卸载 卷组中的 lv
[root@rhel8 ~]# mount /dev/vg1/lv1 /lv1
[root@rhel8 ~]# vgexport /dev/vg1Volume group "vg1" has active logical volumes
[root@rhel8 ~]# vgchange -a n /dev/vg1Logical volume vg1/lv1 contains a filesystem in use.Can't deactivate volume group "vg1" with 1 open logical volume(s)
[root@rhel8 ~]# umount /lv1卸载 卷组 vg1
[root@rhel8 ~]# vgchange -a n /dev/vg10 logical volume(s) in volume group "vg1" now active导出 卷组 vg1
[root@rhel8 ~]# vgexport /dev/vg1Volume group "vg1" successfully exported
[root@rhel8 ~]# pvscanPV /dev/sdb5 is in exported VG vg1 [1020.00 MiB / 0 free]PV /dev/sdc1 is in exported VG vg1 [1020.00 MiB / 8.00 MiB free]PV /dev/sdc2 is in exported VG vg1 [1020.00 MiB / 508.00 MiB free]PV /dev/sdb6 is in exported VG vg1 [1020.00 MiB / 0 free]PV /dev/sdb8 is in exported VG vg1 [1020.00 MiB / 0 free]PV /dev/sda2 VG rhel lvm2 [<29.00 GiB / 0 free]PV /dev/sdb3 lvm2 [500.00 MiB]PV /dev/sdb4 lvm2 [1.00 GiB]Total: 8 [35.46 GiB] / in use: 6 [<33.98 GiB] / in no VG: 2 [<1.49 GiB]导入卷组
[root@rhel8 ~]# vgimport /dev/vg1Volume group "vg1" successfully imported使用 卷组
[root@rhel8 ~]# vgchange -a y /dev/vg14 logical volume(s) in volume group "vg1" now active使用 卷组中的 lv
[root@rhel8 ~]# lvchange -ay /dev/vg1/lv1 