如何从LVM2中删除损坏的磁盘,而其他PV上的数据丢失更少?


15

我有一个带有两个磁盘的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。


如果我愿意vgreduce --removemissing --force media,会发生什么?
kissgyorgy 2011年

Answers:


19
# 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

现在一切正常!


是的...希望您不需要LogVol00 ...现在不见了。
MikeyB

1
最好然后失去一切……
kissgyorgy

1
哦..这就是从一条丢失的镜腿中恢复的方法vgreduce --removemissing --force $vgname吗?
Aquarius Power

如果磁盘损坏,则逻辑卷LogVol00中的数据已消失。从群组中删除它不会再删除任何数据。此外,这就是备份的目的。
jackohug

事实证明,这对我现在多次使用drbd管理ganeti很有用。
dannyman '17

1

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).

1
所以基本上,如果我的根目录/有一个镜像分支,并且该镜像发生故障,那么我认为启动会失败,那么,使用实时发行版iso,我可以运行该命令来再次访问我的系统吗?因此,我也认为最安全的方法是/boot在lvm之外的简单2GB ext4分区上使用live distro iso?
Aquarius Power

1
@AquariusPower,如果缺少镜腿,启动应该不会失败。我个人更喜欢使用mdadmraid和lvm来处理数组,只是将阵列分成逻辑卷。直接从RAID阵列引导而不是使用独立的/ boot引导意味着如果主引导磁盘死了,系统仍然可以正常引导。
psusi 2015年

嗯...在每个PV上,都有一个用于引导的小分区,但是每个分区都是独立的;因此,如果我将这些/boot与raid同步,那么如果其中任何一个失败,我可能可以快速启动;我非常感谢:),我也想您更喜欢mdadm,因为(也许?)lvm镜像同步可能很慢,并且无法及时同步足够的数据以确保在一个PV发生故障(例如停电)时安全无缝启动。
Aquarius Power

1
@AquariusPower,实际上我更喜欢mdadmraid,因为我更喜欢raid10而不是raid1,并且因为它可以改变阵列的形状(例如lvm不能将2磁盘镜像转换为3磁盘raid5)。
psusi
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.