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

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

我们在服务器上遇到了一个磁盘故障,在从 LVM 中移除驱动器之前,我们更换了该磁盘。

服务器有 4 个物理驱动器 (PV),每个驱动器都有自己的卷组 (VG)。每个 VG 都有 2 个或更多逻辑卷 (LV)。现在 LVM 抱怨驱动器丢失。所以我们有一个 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 并不重要,我们只是想删除它们。

正如您所看到的,我们已经尝试了所有提出的建议,但迄今为止没有任何进展。

可以在以下位置检查“lvm dumpconfig”的输出http://pastebin.com/MHiBzrLJ

答案1

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

dmsetup remove vg04-vz
dmsetup remove vg04-swap

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

警告:dmsetup 可能会严重破坏您的磁盘,因此任何将来使用此信息的人请务必阅读手册页。

答案2

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

现在通过重定向1到其中写入删除文件。

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

该设备立即消失。

答案3

vgchange -an /dev/vg04

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

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

ETC。

相关内容