物理驱动器移除后,移除vg和lv

我们在服务器中发生磁盘故障,并在从LVM中取出驱动器之前进行了更换。

服务器有4个物理驱动器(PV),每个都有自己的卷组(VG)。 每个VG有2个或更多逻辑卷(LV)。现在LVM抱怨缺less驱动器。 所以我们有一个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 -an /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 -an /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 

缺less的VG和LV并不重要,我们只是想删除它们。

正如你所看到的,我们已经尝试了所有的build议,到目前为止没有运气。

可以在http://pastebin.com/MHiBzrLJ查看'lvm dumpconfig'的输出

解决scheme是运行dmsetup,在这种情况下是两个命令

 dmsetup remove vg04-vz dmsetup remove vg04-swap 

在做这个之前,我用命令“dmsetup info”检查了两个LV的“打开计数”是零。

警告: dmsetup可能会破坏您的磁盘严重破坏,以便任何人在将来使用这些信息,请确保您阅读手册页。

删除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 

该设备立即消失。

vgchange -an / dev / vg04

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

 lvchange -an /dev/vg04/swap lvchange -an dev/vg04/vz 

等等