卸下物理驱动器后,卸下vg和lv


32

我们在服务器中发生磁盘故障,并在从LVM中删除驱动器之前将其更换。

该服务器有4个物理驱动器(PV),每个都有自己的卷组(VG)。每个VG具有2个或多个逻辑卷(LV)。现在LVM抱怨缺少驱动器。因此,我们有一个带有两个LV的VG(vg04),这些LV变成了孤立的孤儿,超出了我们从系统中清除的需要。

问题是,每当我们运行任何LVM命令时,都会出现以下“读取失败”错误:

# lvscan
  /dev/vg04/swap: read failed after 0 of 4096 at 4294901760: Input/output error
  /dev/vg04/swap: read failed after 0 of 4096 at 4294959104: Input/output error
  /dev/vg04/swap: read failed after 0 of 4096 at 0: Input/output error
  /dev/vg04/swap: read failed after 0 of 4096 at 4096: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 995903864832: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 995903922176: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 0: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 4096: Input/output error

# vgreduce vg04 --removemissing --force
  /dev/vg04/swap: read failed after 0 of 4096 at 4294901760: Input/output error
  /dev/vg04/swap: read failed after 0 of 4096 at 4294959104: Input/output error
  /dev/vg04/swap: read failed after 0 of 4096 at 0: Input/output error
  /dev/vg04/swap: read failed after 0 of 4096 at 4096: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 995903864832: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 995903922176: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 0: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 4096: Input/output error
  Volume group "vg04" not found

# vgchange -a n /dev/vg04
  /dev/vg04/swap: read failed after 0 of 4096 at 4294901760: Input/output error
  /dev/vg04/swap: read failed after 0 of 4096 at 4294959104: Input/output error
  /dev/vg04/swap: read failed after 0 of 4096 at 0: Input/output error
  /dev/vg04/swap: read failed after 0 of 4096 at 4096: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 995903864832: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 995903922176: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 0: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 4096: Input/output error
  Volume group "vg04" not found

# lvchange -a n /dev/vg04/vz
  /dev/vg04/swap: read failed after 0 of 4096 at 4294901760: Input/output error
  /dev/vg04/swap: read failed after 0 of 4096 at 4294959104: Input/output error
  /dev/vg04/swap: read failed after 0 of 4096 at 0: Input/output error
  /dev/vg04/swap: read failed after 0 of 4096 at 4096: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 995903864832: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 995903922176: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 0: Input/output error
  /dev/vg04/vz: read failed after 0 of 4096 at 4096: Input/output error
  Volume group "vg04" not found
  Skipping volume group vg04

丢失的VG和LV并不重要,我们只想删除它们。

如您所见,到目前为止,我们没有尝试过所有提出的建议。

可以从http://pastebin.com/MHiBzrLJ检查“ lvm dumpconfig”的输出

Answers:


46

解决方案是运行dmsetup,在本例中为两个命令

dmsetup remove vg04-vz
dmsetup remove vg04-swap

在执行此操作之前,我使用命令“ dmsetup info”检查了两个LV的“开放计数”为零。

警告: dmsetup可能会严重破坏磁盘,因此以后使用此信息的任何人都请确保已阅读手册页。


3
做到了。太糟糕了,LVM是一个泄漏性的抽象,但是我想这已经足够了。
纳文

1
很好的警告。如果我理解正确,则类似的名称remove_all --force --deferred --retry会吹走每个LVM管理的驱动器。它将像终结者一样不断尝试而不放弃。我非常好奇为什么要使用这样的步枪。
丹·罗斯,

还有一个设备“以极端的偏见终止”(和/或复仇,如果该设备使您整夜忙碌):# dmsetup --force --retry --deferred remove <YOURVG>-<YOURLV>尤其是这样,例如,一个iscsi设备挂起并用# iscsiadm -m node -U all -T <FQDN>
AdamKalisz

9

卸下VMware磁盘后,我遇到了类似的情况/dev/sdb

使用lsscsi确定正在使用的设备(您可能需要安装程序),然后运行lsscsi

# lsscsi
[1:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR10 1.00  /dev/sr0
[2:0:0:0]    disk    VMware   Virtual disk     1.0   /dev/sda
[2:0:1:0]    disk    VMware   Virtual disk     1.0   /dev/sdb <== the removed physical disk
[2:0:2:0]    disk    VMware   Virtual disk     1.0   /dev/sdc

现在用以下命令写入删除文件

# echo 1 > /sys/class/scsi_device/2\:0\:1\:0/device/delete

设备立即不见了。


1
谢谢!!通过dmsetup删除过时的vg1-xyz之后,它消除了“ / dev / sdb:在0的4096在0后失败:输入/输出错误”之类的错误,对我来说非常有效。
猫裤子

1
仅此一项对我有效。你让我今天一整天都感觉很好。
odiszapc

2

vgchange -an / dev / vg04

如果逻辑卷仍处于活动状态,则可能必须

lvchange -a n /dev/vg04/swap
lvchange -a n dev/vg04/vz

等等


2
不幸的是,这也无法解决,它只会引发相同的错误:
RCD 2012年

在我的系统上lvchange -a n <VGNAME>确实有效!
zzeroo
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.