What is lvmetad and how do I disable it?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 9
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 6
  • LVM
  • Exceptions:
    • For RHEL8 hosts:
      • The `lvmetad` daemon does not exist in RHEL8. Starting in RHEL8, the lvm metadata is no longer read from cache, but from the disks directly.[FN.4]

    Issue

    • What is lvmetad and its function? [FN.1]

    • The lvmetad daemon is enabled by default, and I need to disable lvmetad [FN.2]

    • May be seeing issues at boot up when lvmetad is enabled

      Warning: /dev/mapper/rootvg-lv_root does not exist
      Warning: /dev/rootvg/lv_root does not exist
      
    • LVM changes are not reflected by the rest of the nodes in my cluster.

    • After creating a volume group on a node in my cluster the other nodes do not reflect the change.

    Resolution

    To disable[FN.2] the use of lvmetad[FN.1] you will need to make the following changes:

    • Check current feature and service status
    • Disable feature at boot time vis use_lvmetad=0 [FN.4],[FN.5]
    • Disable run-time service(s) using sytemctl
    • Verify changes
    • Rebuild boot image file to reflect above changes (optional) [FN.1]
    • Reboot (optional)

     


     

    1. Check lvmetad current status:

       grep use_lvmetad /etc/lvm/lvm.conf | xargs -I {} echo {} | grep -v "^#"
       systemctl status lvm2-lvmetad                                             # RHEL 8+ only
      
    2. Disable lvmetad feature: ensure the use_lvmetad value in the /etc/lvm/lvm.conf file is set to 0 (off).

       use_lvmetad = 0
      
    3. Disable lvmetad services: We will also need to disable the currently running lvmetad service

      • RHEL 8, 9:

          no actions required, lvmetad is not present in RHEL 8+
        
      • RHEL 7:

          # systemctl stop    lvm2-lvmetad
          # systemctl disable lvm2-lvmetad
          # systemctl stop lvm2-lvmetad.socket
          # systemctl disable lvm2-lvmetad.socket
          # systemctl mask lvm2-lvmetad.socket
        
      • RHEL 6

          # service lvm2-lvmetad stop
          # chkconfig lvm2-lvmetad off
        
    4. Rebuild boot image to pick up changes: After making changes to the /etc/lvm/lvm.conf file, we will need to rebuild the initramfs to ensure the LVM configuration is loaded properly at next boot time. More information is available here: "How to rebuild the initial ramdisk image in Red Hat Enterprise Linux".

       # cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.$(date +%m-%d-%H%M%S).bak
       # dracut -f -v
      
    5. Reboot (optional): Optionally you may wish to reboot to validate the above changes are applied as expected.

     


     

    Same issue persists after above

    • If same issue then collect the below data from the system (for example in maintence mode if the system will not complete boot successfully).

        # cat /etc/fstab > /tmp/fstab.out
        # lsblk > /tmp/lsblk.out
        # df -h > df.out
        # cat /proc/mounts > /tmp/proc-mounts.out
        # journalctl -xb > /tmp/journactl.out
      
    • Compress the collected files.

        # tar -cJf  /tmp/CASENUMBER_lvmdiags.tar.xz /tmp/*out
      
    • Provide the above file and reference to this document to an existing or newly opened Red Hat support case.

     


     

    Footnotes

    • Why you should not disable the lvmetad feature long term.

    • What is lvmetad, and what is it's function?

    • Additional resources for LVM in a cluster/high availability environment:

    • The lvmetad daemon does not exist in RHEL8 so does not, and cannot, be disabled -- it is already implicitly disabled. What replaced it?
      #  systemctl status lvm2-lvmetad
      Unit lvm2-lvmetad.service could not be found.

    • Disabling just the service (systemctl) is not enough to guarantee disabling the feature.
      You must disable the lvmetad feature, not just the service. If just the lvmetad service is disabled (the feature is not disabled), then lvmetad service can, and often will, end up resulting in the lvmetad> getting auto restarted. The feature must be first disabled via the lvmetad=0 configuration clause within the /etc/lvm/lvm.conf lvm configuration file.

    • For a complete rebuild of the lvm cache data utilized by lvmetad, it is recommended that the following commands be run:
      # pvscan
      # vgscan              # especially important if the lvm.conf:filter settings have been changed
      # lvscan
      
    • LVM filtering notes.

    Root Cause

    Components
    Category

    This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.