How to fix "pvs shows unknown device" in RHEL/CentOS 7/8

Advertisement

remove a physical volume listed as an unknown device. pvs shows unknown device in redhat. pvs couldn't find device with uuid. unknown linux device mapper. device for pv not found or rejected by a filter. device for pv not found or rejected by a filter redhat. linux pvremove unknown. couldn't find device with uuid. ailed to find device for physical volume. vgreduce --select. vgreduce unknown. pvscan --cache. how to recover corrupt lvm in linux

 

In this article I will share the steps to recover from a situation where one of our physical volumes becomes unknown device. I found this error while setting up my encrypted LUKS partition and extending the logical volume.

 

Lab Environment (CentOS/RHEL 7/8):

I am using RHEL 8 but the same steps would work on similar OS variants such as centOS 8, RHEL/CentOS 7, SuSE etc.

 

Error: "pvs shows unknown device" and "pvs couldnt find device with uuid"

Below is the error scenario. pvs shows unknown device and pvs couldnt find device with uuid for one of the physical volume.

[root@centos-8 ~]# pvs
  Couldn't find device with uuid Lu7cAF-CUBP-eQ2q-ZR2T-TfJ6-FnzT-EIhheJ.
  PV         VG   Fmt  Attr PSize   PFree
  /dev/sda2  rhel lvm2 a--  <14.50g     0
  [unknown]  rhel lvm2 a-m   <8.00g <8.00g

I had /dev/sdb1 as a Physical Volume but for some reason now pvs shows unknown device for /dev/sdb1. It also throws error as "pvs couldnt find device with uuid'

 

pvscan records which PVs are available on the system, and activates LVs in completed VGs but it fails to activate the unknown device.

[root@centos-8 ~]# pvscan --cache
  Couldn't find device with uuid Lu7cAF-CUBP-eQ2q-ZR2T-TfJ6-FnzT-EIhheJ.
  pvscan[1733] PV /dev/sda2 online.

 

Advertisement

vgreduce command also fails to remove /dev/sdb1 (which is now shown as unknown device) as it also have same problem as "pvs couldnt find device with uuid".

[root@centos-8 ~]# vgreduce rhel /dev/sdb1
  Couldn't find device with uuid pWc1vE-NQS7-4UbM-2n0D-gVvH-uNc2-dlZftM.
  Cannot change VG rhel while PVs are missing.
  Consider vgreduce --removemissing.
  Cannot process volume group rhel
  Failed to find physical volume "/dev/sdb1".

 

Similarly the pvremove command fails as it complains pvs couldnt find device with uuid

[root@centos-8 ~]# pvremove /dev/sdb1
  Couldn't find device with uuid Lu7cAF-CUBP-eQ2q-ZR2T-TfJ6-FnzT-EIhheJ.
  No PV found on device /dev/sdb1.

 

Resolution:

To fix the error "pvs shows unknown device" and "pvs couldnt find device with uuid" execute vgreduce with --removemissing directive.

From the man page:

Removes all missing PVs from the VG, if there are no LVs allocated on them. This resumes normal operation of the VG (new LVs may again be created, changed and so on). If this is not possible because LVs are referencing the missing PVs, this option can be combined with --force to have the command remove any partial LVs.

[root@centos-8 ~]# vgreduce rhel --removemissing
  Couldn't find device with uuid pWc1vE-NQS7-4UbM-2n0D-gVvH-uNc2-dlZftM.
  Wrote out consistent volume group rhel.

Now we don't see any error for missing physical volume UUID

[root@centos-8 ~]# vgs
  VG   #PV #LV #SN Attr   VSize   VFree
  rhel   1   2   0 wz--n- <14.50g    0

pvs command is not showing any unknown device any more.

[root@centos-8 ~]# pvs
  PV         VG   Fmt  Attr PSize   PFree
  /dev/sda2  rhel lvm2 a--  <14.50g    0

 

Recover lost physical volumes

If the disk underlying of the physical volume is not corrupted, there is still a possibility to recover your PV. You can re-create the physical volume using pvcreate command

Advertisement
[root@centos-8 ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created.

Next extend your volume group using vgextend or you can create a new volume group using vgcreate as per your requirement using the new physical volume

[root@centos-8 ~]# vgextend rhel /dev/sdb1
  Volume group "rhel" successfully extended

Verify the vgs output

[root@centos-8 ~]# vgs
  VG   #PV #LV #SN Attr   VSize  VFree
  rhel   2   2   0 wz--n- 22.49g <8.00g

 

Lastly I hope the steps from the article to Fix the LVM error, pvs shows unknown device and pvs couldnt find device with uuid in RHEL/CentOS 7/8 Linux was helpful. So, let me know your suggestions and feedback using the comment section.

 

References:
Remove a Physical Volume listed as an "unknown device"
The pvs command shows 'unkown device' but UUID and LVM labels are still visible

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!