blob: 16b80f9f24ea59b6b825ee1668654a700864a32e [file] [log] [blame]
Samuel Mendoza-Jonasd9398572017-06-05 13:22:05 +10001# Copyright (C) 2009 Red Hat, Inc. All rights reserved.
2#
3# This file is part of LVM2.
4
5# Udev rules for LVM.
6#
7# These rules create symlinks for LVM logical volumes in
8# /dev/VG directory (VG is an actual VG name). Some udev
9# environment variables are set (they can be used in later
10# rules as well):
11# DM_LV_NAME - logical volume name
12# DM_VG_NAME - volume group name
13# DM_LV_LAYER - logical volume layer (blank if not set)
14
15# "add" event is processed on coldplug only!
16ACTION!="add|change", GOTO="lvm_end"
17ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="lvm_end"
18ENV{DM_UUID}!="LVM-?*", GOTO="lvm_end"
19
20# Use DM name and split it up into its VG/LV/layer constituents.
21IMPORT{program}="/usr/sbin/dmsetup splitname --nameprefixes --noheadings --rows $env{DM_NAME}"
22
23# DM_SUBSYSTEM_UDEV_FLAG0 is the 'NOSCAN' flag for LVM subsystem.
24# This flag is used to temporarily disable selected rules to prevent any
25# processing or scanning done on the LVM volume before LVM has any chance
26# to zero any stale metadata found within the LV data area. Such stale
27# metadata could cause false claim of the LV device, keeping it open etc.
28#
29# If the NOSCAN flag is present, backup selected existing flags used to
30# disable rules, then set them firmly so those selected rules are surely skipped.
31# Restore these flags once the NOSCAN flag is dropped (which is normally any
32# uevent that follows for this LV, even an artificially generated one).
33ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", ENV{DM_NOSCAN}="1", ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
34ENV{DM_SUBSYSTEM_UDEV_FLAG0}!="1", IMPORT{db}="DM_NOSCAN", IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD"
35ENV{DM_SUBSYSTEM_UDEV_FLAG0}!="1", ENV{DM_NOSCAN}=="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}", \
36 ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="", ENV{DM_NOSCAN}=""
37
38ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}=="1", GOTO="lvm_end"
39
40OPTIONS+="event_timeout=180"
41
42# Do not create symlinks for inappropriate subdevices.
43ENV{DM_LV_NAME}=="pvmove?*|?*_vorigin", GOTO="lvm_disable"
44ENV{DM_LV_LAYER}=="?*", GOTO="lvm_disable"
45
46# Create symlinks for top-level devices only.
47ENV{DM_VG_NAME}=="?*", ENV{DM_LV_NAME}=="?*", SYMLINK+="$env{DM_VG_NAME}/$env{DM_LV_NAME}", GOTO="lvm_end"
48
49LABEL="lvm_disable"
50ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1"
51ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
52OPTIONS:="nowatch"
53
54LABEL="lvm_end"