Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2101025

Summary: what is the expected behavior when using '--devicesfile <file>' with cmds that have the power to create that file (pvcreate|vgcreate)
Product: Red Hat Enterprise Linux 8 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: LVM and device-mapper development team <lvm-team>
lvm2 sub component: Devices, Filtering and Stacking QA Contact: cluster-qe <cluster-qe>
Status: CLOSED NOTABUG Docs Contact:
Severity: medium    
Priority: unspecified CC: agk, heinzm, jbrassow, msnitzer, prajnoha, teigland, zkabelac
Version: 8.6Flags: pm-rhel: mirror+
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-03-08 15:37:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Corey Marthaler 2022-06-24 21:45:31 UTC
Description of problem:
I noticed this while attempting to verify bug 2090949. The man pages for pvcreate and vgcreate (and other LVM cmds that support it) state that when using this option "The file must exist in /etc/lvm/devices/". Well, that doesn't appear to be the case for these two cmds that have the power to create it, they will create the file with the name given which can lead to all kinds of fun seen below.


pvcreate(8)
       --devicesfile String
              A  file  listing  devices  that  LVM should use.  The file must exist in /etc/lvm/devices/ and is managed with the lvmdevices(8) command.
              This overrides the lvm.conf(5) devices/devicesfile and devices/use_devicesfile settings.

vgcreate(8)
       --devicesfile String
              A file listing devices that LVM should use.  The file must exist in /etc/lvm/devices/ and is  managed  with  the  lvmdevices(8)  command.
              This overrides the lvm.conf(5) devices/devicesfile and devices/use_devicesfile settings.



# Use default
[root@hayes-02 ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created.

[root@hayes-02 devices]# pwd
/etc/lvm/devices
[root@hayes-02 devices]# cat system.devices 
# LVM uses devices listed in this file.
# Created by LVM command pvcreate pid 126122 at Fri Jun 24 16:31:11 2022
VERSION=1.1.474
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd29e81db0cefc DEVNAME=/dev/sdb1 PVID=ZhgXcbeSe33ugojjV6MyJsdK6Nw24qqX PART=1


# Use an alternative file
[root@hayes-02 ~]# pvcreate /dev/sdc1 --devicesfile invalid1
  Physical volume "/dev/sdc1" successfully created.
[root@hayes-02 devices]# cat system.devices 
# LVM uses devices listed in this file.
# Created by LVM command pvcreate pid 126122 at Fri Jun 24 16:31:11 2022
VERSION=1.1.474
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd29e81db0cefc DEVNAME=/dev/sdb1 PVID=ZhgXcbeSe33ugojjV6MyJsdK6Nw24qqX PART=1
[root@hayes-02 devices]# cat invalid1 
# LVM uses devices listed in this file.
# Created by LVM command pvcreate pid 126138 at Fri Jun 24 16:32:07 2022
VERSION=1.1.1
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd29ee1e0945a8 DEVNAME=/dev/sdc1 PVID=gfU8SjiJmng3TT0NPb2lBfZ7wCDgoq0b PART=1




[root@hayes-02 ~]# pvs
  PV         VG Fmt  Attr PSize  PFree 
  /dev/sdb1     lvm2 ---  <1.82t <1.82t
[root@hayes-02 ~]# pvs --devicesfile invalid1
  PV         VG Fmt  Attr PSize  PFree 
  /dev/sdc1     lvm2 ---  <1.82t <1.82t


[root@hayes-02 ~]# vgcreate test /dev/sdb1 /dev/sdc1
  Volume group "test" successfully created

[root@hayes-02 devices]# cat system.devices 
# LVM uses devices listed in this file.
# Created by LVM command vgcreate pid 126165 at Fri Jun 24 16:34:01 2022
VERSION=1.1.475
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd29e81db0cefc DEVNAME=/dev/sdb1 PVID=ZhgXcbeSe33ugojjV6MyJsdK6Nw24qqX PART=1
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd29ee1e0945a8 DEVNAME=/dev/sdc1 PVID=gfU8SjiJmng3TT0NPb2lBfZ7wCDgoq0b PART=1



[root@hayes-02 ~]# vgcreate test2 /dev/sdd1 /dev/sde1 --devicesfile invalid2
  Physical volume "/dev/sdd1" successfully created.
  Physical volume "/dev/sde1" successfully created.
  Volume group "test2" successfully created

[root@hayes-02 devices]# cat system.devices 
# LVM uses devices listed in this file.
# Created by LVM command vgcreate pid 126165 at Fri Jun 24 16:34:01 2022
VERSION=1.1.475
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd29e81db0cefc DEVNAME=/dev/sdb1 PVID=ZhgXcbeSe33ugojjV6MyJsdK6Nw24qqX PART=1
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd29ee1e0945a8 DEVNAME=/dev/sdc1 PVID=gfU8SjiJmng3TT0NPb2lBfZ7wCDgoq0b PART=1

[root@hayes-02 devices]# cat invalid2
# LVM uses devices listed in this file.
# Created by LVM command vgcreate pid 126183 at Fri Jun 24 16:35:01 2022
VERSION=1.1.1
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd29f31e631f3e DEVNAME=/dev/sdd1 PVID=Ku7byxn6scKnUJGSa3VNqIjojJqel6uJ PART=1
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd29f91ebe756c DEVNAME=/dev/sde1 PVID=IP1RMdvXulRqdWCFbN76fv770Rtor6Rm PART=1

[root@hayes-02 ~]# lvcreate -L 100M test2
  Volume group "test2" not found
  Cannot process volume group test2

[root@hayes-02 ~]# lvcreate -L 100M test2 --devicesfile invalid2
  Logical volume "lvol0" created.


Version-Release number of selected component (if applicable):
kernel-4.18.0-400.el8    BUILT: Fri Jun 10 13:11:32 CDT 2022
lvm2-2.03.14-4.el8    BUILT: Wed Jun 15 17:14:34 CDT 2022
lvm2-libs-2.03.14-4.el8    BUILT: Wed Jun 15 17:14:34 CDT 2022

Comment 1 David Teigland 2022-06-24 22:12:03 UTC
pvcreate and vgcreate are special cases which are meant to create the named devices file if it doesn't exist.  Perhaps we should make an exception to the exception when a non-default file name is provided (--devicesfile "foo".)  i.e. if you're using a non-standard --devicesfile "foo" where "foo" doesn't exist, then pvcreate/vgcreate will fail like other commands rather than create foo.  I don't know if adding another exception is making things better or worse, more confusing or less.  If we leave it alone, we could tweak the --devicesfile description for just pvcreate/vgcreate (the same option description is currently applied to every command.)

Comment 2 David Teigland 2022-06-24 22:23:14 UTC
The special case for pvcreate/vgcreate is primarily for them to create system.devices (not custom devices files.)  And there's another special case in that they won't create system.devices if other VGs are already visible on the system.  These special cases around creating system.devices is to make it easier to enable the devices file feature by default without disrupting users and workflows.