LVM未知设备:如何恢复?

LVM未知设备:如何恢复?

我有一台有两个硬盘的服务器,我以为我已经正确安装了LVM,直到我发现第二个硬盘实际上似乎没有被使用。我调查了这个问题并按照网上找到的一些说明进行操作,但问题变得更糟。显然,我最初的错误是在pvremove我应该使用的时候删除了物理卷mvreduce

我在下面附上更多信息。我正在使用 Ubuntu Server 14.04 LTS。我还应该提到的是,我在第二个硬盘驱动器上没有任何需要恢复的数据,该磁盘可以完全擦除。

我的逻辑卷apollo2-vg应该由sda3和组成sdb

root@apollo2:~# lsblk
NAME                               MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                                  8:0    0 745.2G  0 disk 
├─sda1                               8:1    0   512M  0 part /boot/efi
├─sda2                               8:2    0   244M  0 part /boot
└─sda3                               8:3    0 744.5G  0 part 
  ├─apollo2--vg-root (dm-0)        252:0    0   1.2T  0 lvm  /
  └─apollo2--vg-swap_1 (dm-1)      252:1    0 255.9G  0 lvm  [SWAP]
sdb                                  8:16   0 745.2G  0 disk 
└─apollo2--vg-root (dm-0)          252:0    0   1.2T  0 lvm  /

以下是我的分区概述:

root@apollo2:~# parted -l
Model: ATA LITEON IT ECE-80 (scsi)
Disk /dev/sda: 800GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End    Size   File system  Name  Flags
 1      1049kB  538MB  537MB  fat32              boot
 2      538MB   794MB  256MB  ext2
 3      794MB   800GB  799GB                     lvm


Model: ATA LITEON IT ECE-80 (scsi)
Disk /dev/sdb: 800GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End  Size  File system  Name  Flags


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/apollo2--vg-root: 1325GB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End     Size    File system  Flags
 1      0.00B  1325GB  1325GB  ext4

Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/apollo2--vg-swap_1: 275GB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End    Size   File system     Flags
 1      0.00B  275GB  275GB  linux-swap(v1)

问题是sdb(在第二个硬盘上)现在丢失了:

root@apollo2:~# pvscan
Couldn't find device with uuid f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe.
PV /dev/sda3        VG apollo2-vg   lvm2 [744.47 GiB / 0    free]
PV unknown device   VG apollo2-vg   lvm2 [745.21 GiB / 0    free]
Total: 2 [1.45 TiB] / in use: 2 [1.45 TiB] / in no VG: 0 [0   ]

这得到了证实lvdisplay

root@apollo2:~# lvdisplay
Couldn't find device with uuid f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe.
--- Logical volume ---
LV Path                /dev/apollo2-vg/root
LV Name                root
VG Name                apollo2-vg
LV UUID                W7afVo-nWcn-qwDf-hLvB-uFkV-LbEL-iX7FLj
LV Write Access        read/write
LV Creation host, time apollo2, 2015-03-14 17:20:12 +0100
LV Status              available
# open                 1
LV Size                1.20 TiB
Current LE             315847
Segments               2
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           252:0

--- Logical volume ---
LV Path                /dev/apollo2-vg/swap_1
LV Name                swap_1
VG Name                apollo2-vg
LV UUID                aHegDA-NP47-dkUg-nY3L-HNp7-Y8xM-lflNFs
LV Write Access        read/write
LV Creation host, time apollo2, 2015-03-14 17:20:12 +0100
LV Status              available
# open                 2
LV Size                255.90 GiB
Current LE             65511
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           252:1

pvdisplay

root@apollo2:~# pvdisplay
Couldn't find device with uuid f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe.
--- Physical volume ---
PV Name               /dev/sda3
VG Name               apollo2-vg
PV Size               744.47 GiB / not usable 4.00 MiB
Allocatable           yes (but full)
PE Size               4.00 MiB
Total PE              190584
Free PE               0
Allocated PE          190584
PV UUID               2p7KM5-dWVY-z1uw-auBy-QXHQ-6aVl-mezqAY

--- Physical volume ---
PV Name               unknown device
VG Name               apollo2-vg
PV Size               745.21 GiB / not usable 1.84 MiB
Allocatable           yes (but full)
PE Size               4.00 MiB
Total PE              190774
Free PE               0
Allocated PE          190774
PV UUID               f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe

根据在互联网上找到的建议,我尝试了很多方法,例如重新创建丢失的设备:

root@apollo2:~# pvcreate /dev/sdb --uuid=f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe --norestorefile
Device /dev/sdb not found (or ignored by filtering).

或者将其从卷组中删除:

root@apollo2:~# vgreduce --removemissing --verbose apollo2-vg
Finding volume group "apollo2-vg"
Couldn't find device with uuid f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe.
There are 1 physical volumes missing.
Trying to open VG apollo2-vg for recovery...
Couldn't find device with uuid f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe.
There are 1 physical volumes missing.
Archiving volume group "apollo2-vg" metadata (seqno 11).
WARNING: Partial LV root needs to be repaired or removed. 
There are still partial LVs in VG apollo2-vg.
To remove them unconditionally use: vgreduce --removemissing --force.
Proceeding to remove empty missing PVs.
Creating volume group backup "/etc/lvm/backup/apollo2-vg" (seqno 12).

root@apollo2:~# vgreduce --removemissing --force --verbose apollo2-vg
Finding volume group "apollo2-vg"
Couldn't find device with uuid f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe.
There are 1 physical volumes missing.
Trying to open VG apollo2-vg for recovery...
Couldn't find device with uuid f2hTAw-yDWd-8DH1-1fhy-Kfwk-mIui-6isUfe.
There are 1 physical volumes missing.
Archiving volume group "apollo2-vg" metadata (seqno 12).
Removing partial LV root.
Logical volume apollo2-vg/root contains a filesystem in use.

不幸的是,我尝试过的解决方案都不起作用。我对 LVM 没有太多经验,如果我在没有真正了解发生了什么的情况下继续尝试解决问题,我担心问题可能会变得更糟。

我读到一些有类似问题的人无法正确重新启动机器,这将是最坏的情况。

希望有一个简单的解决方案。预先感谢您的帮助!

答案1

一个月前,我的镜像卷也遇到了同样的问题。我通过更新到lvm2-2.02.116-3.fc21.x86_64 lvm2解决了这个问题。

然后我可以运行:

vgreduce --removemissing --verbose myVG_NAME

答案2

这个链接将有助于在 SUSE 中修复它。

LVM 卷组显示“未知设备”

本文档 (3803380) 的提供受本文档末尾的免责声明的约束。

环境 SUSE Linux Enterprise Server 11 SUSE Linux Enterprise Server 10 SUSE Linux Enterprise Server 9 逻辑卷管理版本 2 (LVM)

情况 当激活 LVM 卷组时,它显示“未知设备”错误。逻辑卷将不会激活。

# pvscan

Couldn't find device with uuid '56ogEk-OzLS-cKBc-z9vJ-kP65-DUBI-hwZPSu'.
Couldn't find device with uuid '56ogEk-OzLS-cKBc-z9vJ-kP65-DUBI-hwZPSu'.
PV /dev/sdb VG ops lvm2 [200.00 MB / 0 free]
PV unknown device VG ops lvm2 [200.00 MB / 0 free]
PV /dev/sdd VG sales ops [200.00 MB / 150.00 MB free]
Total: 4 [600.00 MB] / in use: 4 [600.00 MB] / in no VG: 0 [0 ]

当从包含多个磁盘的卷组中删除物理磁盘时,也会产生部分模式卷组。在下面的示例中,lrg 卷组缺少其中一个磁盘,从而导致部分模式。

# /sbin/vgs

Couldn't find device with uuid ntc7O9-wevl-ZtXz-xESe-wwUB-G8WZ-6RtjxB.
  VG   #PV #LV #SN Attr   VSize   VFree 
  asm    1   2   0 wz--n- 300.00m  60.00m
  ceo    1   1   0 wz--n- 252.00m  12.00m
  lrg    4   1   0 wz-pn-   1.19g 716.00m
  sys    1   3   0 wz--n-   3.50g  12.00m

通常,此错误意味着物理设备丢失或设备上的 LVM 元数据已损坏或丢失。恢复卷的一般过程是:

  1. 更换发生故障或丢失的磁盘
  2. 恢复丢失磁盘的 UUID
  3. 恢复LVM元数据
  4. 修复LVM设备上的文件系统

场景一:

如果磁盘刚刚被移除而没有准备 LVM,则只需将磁盘放回服务器中并重新启动即可。如果要删除设备,请首先从卷组中删除磁盘,然后从服务器中删除。

场景2:

如果磁盘已安装在服务器中,但仍未知,则 LVM 元数据可能会丢失。您需要恢复设备的 UUID,如 所示pvscan,然后运行vgcfgrestore恢复 LVM 元数据。例如,

pvcreate --uuid 56ogEk-OzLS-cKBc-z9vJ-kP65-DUBI-hwZPSu /dev/sdc
vgcfgrestore ops
vgchange -ay ops
fsck /dev/ops/

注意:确保您使用正确的 UUID,如 所示pvscan。否则,vgcfgrestore可能会失败。

原因:卷组中包含的物理磁盘已被删除。

答案3

--restorefile关于需要使用 的问题--uuid,请在 上列出目录/etc/lvm/archive以找到适合您的 vg 的最新目录。那么命令的格式就变成:

pvcreate --uuid "your_uuid" --restorefile /etc/lvm/archive/your_restore_file.vg  /dev/your_disk

相关内容