pvcreate 无法初始化物理卷

pvcreate not able to initialize physical volume

我有一些每次都会调用 pvcreate 的应用程序。

我可以在我的虚拟机中看到卷如下:

$ pvscan

  PV /dev/vda5   VG ubuntu-vg       lvm2 [99.52 GiB / 0    free]
  Total: 1 [99.52 GiB] / in use: 1 [99.52 GiB] / in no VG: 0 [0   ]

$ pvcreate --metadatasize=128M --dataalignment=256K '/dev/vda5'

Can't initialize physical volume "/dev/vda5" of volume group "ubuntu-vg" without -ff

$ pvcreate --metadatasize=128M --dataalignment=256K '/dev/vda5' -ff

Really INITIALIZE physical volume "/dev/vda5" of volume group "ubuntu-vg" [y/n]? y
  Can't open /dev/vda5 exclusively.  Mounted filesystem?

我也尝试过 wipsfs 并观察到上述命令的相同结果

$ wipefs -af /dev/vda5

/dev/vda5: 8 bytes were erased at offset 0x00000218 (LVM2_member): 4c 56 4d 32 20 30 30 31

如何执行 pvcreate? 要为我的虚拟机添加什么吗?

您的硬盘 (/dev/vda5) 似乎已经在您的 ubuntu-vg 中使用了。我认为您不能在 2 个不同的 PV 中使用相同的硬盘分区。否则无法再次添加。