![如何从 LVM2 中移除坏磁盘,同时减少其他 PV 上的数据丢失?](https://linux22.com/image/563864/%E5%A6%82%E4%BD%95%E4%BB%8E%20LVM2%20%E4%B8%AD%E7%A7%BB%E9%99%A4%E5%9D%8F%E7%A3%81%E7%9B%98%EF%BC%8C%E5%90%8C%E6%97%B6%E5%87%8F%E5%B0%91%E5%85%B6%E4%BB%96%20PV%20%E4%B8%8A%E7%9A%84%E6%95%B0%E6%8D%AE%E4%B8%A2%E5%A4%B1%EF%BC%9F.png)
我有一个包含两个磁盘的 LVM2 卷。较大的磁盘已损坏,因此我无法执行 pvmove。将其从组中移除以从另一个磁盘保存最多数据的最佳方法是什么?这是我的 pvdisplay 输出:
Couldn't find device with uuid WWeM0m-MLX2-o0da-tf7q-fJJu-eiGl-e7UmM3.
--- Physical volume ---
PV Name unknown device
VG Name media
PV Size 1,82 TiB / not usable 1,05 MiB
Allocatable yes (but full)
PE Size 4,00 MiB
Total PE 476932
Free PE 0
Allocated PE 476932
PV UUID WWeM0m-MLX2-o0da-tf7q-fJJu-eiGl-e7UmM3
--- Physical volume ---
PV Name /dev/sdb1
VG Name media
PV Size 931,51 GiB / not usable 3,19 MiB
Allocatable yes (but full)
PE Size 4,00 MiB
Total PE 238466
Free PE 0
Allocated PE 238466
PV UUID oUhOcR-uYjc-rNTv-LNBm-Z9VY-TJJ5-SYezce
所以我想删除未知设备(系统中不存在)。没有新磁盘可以做到这一点吗?文件系统是 ext4。
答案1
# pvdisplay
Couldn't find device with uuid EvbqlT-AUsZ-MfKi-ZSOz-Lh6L-Y3xC-KiLcYx.
--- Physical volume ---
PV Name /dev/sdb1
VG Name vg_srvlinux
PV Size 931.51 GiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 238466
Free PE 0
Allocated PE 238466
PV UUID xhwmxE-27ue-dHYC-xAk8-Xh37-ov3t-frl20d
--- Physical volume ---
PV Name unknown device
VG Name vg_srvlinux
PV Size 465.76 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 119234
Free PE 0
Allocated PE 119234
PV UUID EvbqlT-AUsZ-MfKi-ZSOz-Lh6L-Y3xC-KiLcYx
# vgreduce --removemissing --force vg_srvlinux
Couldn't find device with uuid EvbqlT-AUsZ-MfKi-ZSOz-Lh6L-Y3xC-KiLcYx.
Removing partial LV LogVol00.
Logical volume "LogVol00" successfully removed
Wrote out consistent volume group vg_srvlinux
# pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name vg_srvlinux
PV Size 931.51 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 238466
Free PE 238466
Allocated PE 0
PV UUID xhwmxE-27ue-dHYC-xAk8-Xh37-ov3t-frl20d
现在一切正常!
答案2
从vgreduce
手册页中:
--removemissing
Removes all missing physical volumes from the volume group, if there are no logical volumes
allocated on those. This resumes normal operation of the volume group (new logical volumes
may again be created, changed and so on).
If this is not possible (there are logical volumes referencing the missing physical volumes)
and you cannot or do not want to remove them manually, you can run this option with --force
to have vgreduce remove any partial LVs.
Any logical volumes and dependent snapshots that were partly on the missing disks get removed
completely. This includes those parts that lie on disks that are still present.
If your logical volumes spanned several disks including the ones that are lost, you might
want to try to salvage data first by activating your logical volumes with --partial as
described in lvm (8).