[linux-lvm] what creates the symlinks in /dev/<volgroup> ?

Chris Friesen chris.friesen at windriver.com
Thu Jun 23 16:35:59 UTC 2016


On 06/23/2016 02:34 AM, Zdenek Kabelac wrote:
> Dne 22.6.2016 v 16:52 Chris Friesen napsal(a):
>> On 06/22/2016 03:23 AM, Zdenek Kabelac wrote:
>>> Dne 21.6.2016 v 17:22 Chris Friesen napsal(a):
>>>> I'm using the stock CentOS7 version, I think.
>>>>
>>>>   LVM version:     2.02.130(2)-RHEL7 (2015-12-01)
>>>>   Library version: 1.02.107-RHEL7 (2015-12-01)
>>>>   Driver version:  4.33.0
>>>>
>>>> So are you saying that nobody should run "vgscan --mknodes" on a system where
>>>> udev is managing the symlinks?
>>>
>>> Yes - on such system this command should be used only in case of 'emergency',
>>> udev doesn't work properly and you need links.
>>>
>>> The links however will not be known to udev and likely whole system is
>>> going to be crashing soon or is misconfigured in major way.
>>
>> Okay, I'll see if I can get the call to vgscan removed.  But even so wouldn't
>> it make sense to have vgscan use the same logic as udev in terms of what
>> symlinks to make and where to make them to?
>
> It *IS* using same logic.
>
> If the link is not there - the bug is in your udev rules.
>
> When udev is properly configured, vgscan should not show missing link.

It doesn't seem to work this way in practice on a stock CentOS system.  Here's 
the sequence:

1) create a volume group:
"vgcreate chris-volumes /dev/loop2"
At this point there is no /dev/chris-volumes directory.

2) Create a thin pool in the volume group:
"lvcreate -L 1.8GB -T chris-volumes/chris-volumes-pool"

Now udev creates a /dev/chris-volumes directory with a link for the thin pool:
[root at centos7 centos]# ls -l /dev/chris-volumes
total 0
lrwxrwxrwx. 1 root root 7 Jun 23 12:22 chris-volumes-pool -> ../dm-9

3) Create a thin volume in the thin pool:
"lvcreate -V1G -T chris-volumes/chris-volumes-pool -n thinvolume"

Now the link for the thin pool itself has disappeared:
[root at centos7 centos]# ls -l /dev/chris-volumes
total 0
lrwxrwxrwx. 1 root root 8 Jun 23 12:23 thinvolume -> ../dm-11

(At this point /dev/mapper/chris--volumes-chris--volumes--pool-tpool points to 
dm-9 and /dev/mapper/chris--volumes-chris--volumes--pool points to dm-10.)


4) If I run "vgscan --mknodes", it re-creates the thin pool link, but pointing 
to the /dev/mapper name instead of directly to the /dev/dm-*.  Also, it's 
indirectly pointing to /dev/dm-10 where before it was pointing to /dev/dm-9:

[root at centos7 centos]# vgscan --mknodes
   Configuration setting "snapshot_autoextend_percent" invalid. It's not part of 
any section.
   Configuration setting "snapshot_autoextend_threshold" invalid. It's not part 
of any section.
   Reading all physical volumes.  This may take a while...
   Found volume group "chris-volumes" using metadata type lvm2
   Found volume group "centos" using metadata type lvm2
   Found volume group "cinder-volumes" using metadata type lvm2
   The link /dev/chris-volumes/chris-volumes-pool should have been created by 
udev but it was not found. Falling back to direct link creation.
[root at centos7 centos]# ls -l /dev/chris-volumes
total 0
lrwxrwxrwx. 1 root root 47 Jun 23 12:25 chris-volumes-pool -> 
/dev/mapper/chris--volumes-chris--volumes--pool
lrwxrwxrwx. 1 root root  8 Jun 23 12:23 thinvolume -> ../dm-11


5) If I run "vgchange -an chris-volumes", I'm left with a /dev/chris-volumes 
directory containing a broken symlink (broken because 
/dev/mapper/chris--volumes-chris--volumes--pool doesn't exist anymore):

[root at centos7 centos]# ls -l /dev/chris-volumes
total 0
lrwxrwxrwx. 1 root root 47 Jun 23 12:25 chris-volumes-pool -> 
/dev/mapper/chris--volumes-chris--volumes--pool



It looks like /usr/lib/udev/rules.d/11-dm-lvm.rules is what makes the 
/dev/<VG>/<LV> symlink for normal devices, but for a thin pool with a thin 
volume in it it will exit without making a symlink because 
DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG=1 is set.

[root at centos7 centos]# udevadm info /dev/chris-volumes/chris-volumes-pool
P: /devices/virtual/block/dm-10
N: dm-10
E: DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG=1


Chris




More information about the linux-lvm mailing list