7.4. 修复物理卷元数据


如果不小心覆盖或者破坏了卷组物理卷元数据区域,您会看到出错信息显示元数据区域不正确,或者系统无法使用特定的 UUID 找到物理卷。您可能需要通过在物理卷的元数据区域写入新的元数据来修复物理卷数据,指定相同的 UUID 作为丢失的元数据。

警告

在正常的 LVM 逻辑卷中您应该不会进行这个操作过程。如果您指定了不正确的 UUID,您会丢失您的数据。
下面的例子显示排序的输出解个,您可以看到您的元数据是丢了还是被破坏了。
# lvs -a -o +devices
  Couldn't find device with uuid 'FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk'.
  Couldn't find all physical volumes for volume group VG.
  Couldn't find device with uuid 'FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk'.
  Couldn't find all physical volumes for volume group VG.
  ...
Copy to Clipboard Toggle word wrap
通过查看 /etc/lvm/archive 目录,您可能可以找到被覆盖的物理卷 UUID。在文件 VolumeGroupName_xxxx.vg 中查找该卷组最后的有效归档 LVM 元数据。
另外,您可以找到失活的卷并设定 partial-P)选项,这样您就可以找到丢失的被破坏的物理卷的 UUID。
# vgchange -an --partial
  Partial mode. Incomplete volume groups will be activated read-only.
  Couldn't find device with uuid 'FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk'.
  Couldn't find device with uuid 'FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk'.
  ...
Copy to Clipboard Toggle word wrap
Use the --uuid and --restorefile arguments of the pvcreate command to restore the physical volume. The following example labels the /dev/sdh1 device as a physical volume with the UUID indicated above, FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk. This command restores the physical volume label with the metadata information contained in VG_00050.vg, the most recent good archived metadata for the volume group. The restorefile argument instructs the pvcreate command to make the new physical volume compatible with the old one on the volume group, ensuring that the new metadata will not be placed where the old physical volume contained data (which could happen, for example, if the original pvcreate command had used the command line arguments that control metadata placement, or if the physical volume was originally created using a different version of the software that used different defaults). The pvcreate command overwrites only the LVM metadata areas and does not affect the existing data areas.
# pvcreate --uuid "FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk" --restorefile /etc/lvm/archive/VG_00050.vg /dev/sdh1
  Physical volume "/dev/sdh1" successfully created
Copy to Clipboard Toggle word wrap
You can then use the vgcfgrestore command to restore the volume group's metadata.
# vgcfgrestore VG
  Restored volume group VG
Copy to Clipboard Toggle word wrap
现在您可以显示逻辑卷。
# lvs -a -o +devices
  LV     VG   Attr   LSize   Origin Snap%  Move Log Copy%  Devices
  stripe VG   -wi--- 300.00G                               /dev/sdh1 (0),/dev/sda1(0)
  stripe VG   -wi--- 300.00G                               /dev/sdh1 (34728),/dev/sdb1(0)
Copy to Clipboard Toggle word wrap
下面的命令激活卷并显示激活的卷。
# lvchange -ay /dev/VG/stripe
[root@link-07 backup]# lvs -a -o +devices
  LV     VG   Attr   LSize   Origin Snap%  Move Log Copy%  Devices
  stripe VG   -wi-a- 300.00G                               /dev/sdh1 (0),/dev/sda1(0)
  stripe VG   -wi-a- 300.00G                               /dev/sdh1 (34728),/dev/sdb1(0)
Copy to Clipboard Toggle word wrap
如果磁盘中的 LVM 元数据使用至少覆盖了它的数据的空间大小,这个命令可以恢复物理卷。如果覆盖元数据的数据超过了元数据区域,那么就有可能损害到卷中的数据。您可能可以使用 fsck 命令修复那些数据。
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat