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


LUKS, Error, Linux

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.

 

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

[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

Deepak Prasad

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can connect with him on his LinkedIn profile.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

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 send mail to admin@golinuxcloud.com

Thank You for your support!!

7 thoughts on “How to fix "pvs shows unknown device" in RHEL/CentOS 7/8”

    • pvscan will scan the available devices and instruct the lvmetad daemon to update its cached state accordingly and if it encounters that metadata of any of the devices is corrupted or is unable to find a required PV UUID within the metadata of any of the disks scanned then those devices are marked as unknown device.

      Reply
  1. Hello,
    I have same error
    could not find device with uuid #### refusing activation of partial lv
    I can see lv_root and /boot are find on /dev/sda
    but lv_home is missing due to pv is unknown which is /dev/sdb1

    If I followed you way bey reducing the missing from VG then will lose everything!!!
    I can not see /dev/sdb disk and wanna recover the LVM , what should I do ??

    Reply
    • After you have recovered your Physical Volume you can try to recover the data of your logical volume using vgcfgrestore. You can give it a try in your lab environment if you have any before going to production.

      Reply
  2. Nice but i have one question.
    first partition is lvm and the second partition is also lvm and increases with the first partition. Meanwhile data will exist.At that time I am using the recovery phase of lost physical versions.
    Will the data exist at that time?

    Reply
    • I am not sure if I understand your question completely, do you mean you have a PV with 2 logical volumes and you want to recover this PV without data loss?
      if yes you can use lvs -o +devices to check the backend disk partition used for your LVM and then move your data using pvmove.

      Reply

Leave a Comment