如何使用 vgmknodes 在 /dev 目录下重新创建 LVM 设备文件

服务器崩溃或者由于人为错误后,在 /dev 目录下看不到卷组设备文件。

系统崩溃后,可能是由于文件系统损坏,设备文件被从文件系统中删除。

# cd /dev
# ls vg01
ls: cannot access vg01: No such file or directory

如果我们检查 lvdisplay 命令的输出,我们会看到 vg 完好无损,没有任何错误。

# lvdisplay
  --- Logical volume --
  LV Path                /dev/vg01/lv01
  LV Name                lv01
  VG Name                vg01
  LV UUID                iP1MbY-LPMY-nmym-iY2B-CCRJ-ElVY-5L1mql
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2017-10-11 21:39:45 +0530
  LV Status              not available
  # open                 1
  LV Size                10.00 GiB
  Current LE             2560
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:3
之路 on it Road.com

创建 LVM 设备

  1. 如果我们尝试使用备份恢复卷组,命令 vgcfgrestore 将失败。
# vgcfgrestore -f /etc/lvm/backup/vg01 /dev/sdc
2ba3ce899000-2ba3ce89a000 rw-p 2ba3ce899000 00:00 0
2ba3ce8a5000-2ba3ce8aa000 rw-p 2ba3ce8a5000 00:00 0
2ba3ce8aa000-2ba3d1e83000 r--p 00000000 fd:00 77807        /usr/lib/locale/locale-archive
7fff26a43000-7fff26a58000 rw-p 7ffffffea000 00:00 0        [stack]
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0    [vdso]
Aborted
  1. 为了在 /dev/ 下重新创建 LVM 设备,我们必须使用 vgmknodes 命令。
    使用带有详细选项的 vgmknodes 命令:
# vgmknodes -vv
日期:2020-09-17 00:13:47 来源:oir作者:oir