How to configure lvm filter, when local disk name is not persistent?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 6, 7, 8
  • device-mapper-multipath
  • lvm2

Issue

  • How to configure lvm filter, when local disk name is not persistent?
  • Local disk name changing across system reboot.
  • Local disk blacklisted in /etc/multipath.conf

Resolution

There are 2 methods to resolve this issue.

  • Method1: configure the lvm filter using the symbolic link of the disk in /dev/disk/by-id which is based on the disk WWID.

    • First, find the id of the disk in /dev/disk/by-id

        # ll /dev/disk/by-id
        ...
        lrwxrwxrwx. 1 root root   9 Dec 16 01:47 scsi-3600aaaaaaaaaaaaaaaaaaaaaaaaaaaaa -> ../../sde
      
    • Then configure the lvm filter to include the symlink found above:

        filter = [ "a|/dev/disk/by-id/<id of disk>.*|", "a|/dev/mapper/mpath.*|", "r|.*|" ]
      

      Example:

        filter = [ "a|/dev/disk/by-id/scsi-3600aaaaaaaaaaaaaaaaaaaaaaaaaaaaa.*|", "a|/dev/mapper/mpath.*|", "r|.*|" ]
      

      The filter above scans only lvm metadata in /dev/disk/by-id/scsi-3600aaaaaaaaaaaaaaaaaaaaaaaaaaaaa (and its partitions) and in multipath devices (and their partitions) and rejects all other devices.

  • Method2: Set the priority for loading HBA driver module and fix local disk name as sda.
    Then configure lvm filter as below

      filter = [ "a|/dev/sda[0-9]$|", "a|/dev/mapper/mpath.*|", "r|.*|" ]
    

Note: If custom names are used for multipath devices or user_friendly_names is set to no in multipath.conf, then the filters in both methods above will need to be adjusted to match the names of multipath devices.

Root Cause

The /dev/sdX disk names created for scsi devices are not persistent across reboot. They depend on the order of discovery and, depending on the hardware, they can be randomly assigned.

Diagnostic Steps

Note: This solution is not useful for RHEL5. There's no udev rule processing during the initramfs on RHEL5. The extra /dev/disk/by-* symlinks are added when udevd starts, after the switch to the real rootfs.

SBR
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.