1cbe9429808112265e977f41f3ceaea543738b59
[multipath-tools/.git] / kpartx / kpartx.rules
1 #
2 # persistent links for device-mapper devices
3 # only hardware-backed device-mapper devices (ie multipath, dmraid,
4 # and kpartx) have meaningful persistent device names
5 #
6
7 KERNEL!="dm-*", GOTO="kpartx_end"
8 ACTION!="add|change", GOTO="kpartx_end"
9 ENV{DM_UUID}!="?*", GOTO="kpartx_end"
10
11 # kpartx_id is very robust, it works for suspended maps and maps
12 # with 0 dependencies
13 IMPORT{program}=="kpartx_id %M %m $env{DM_UUID}"
14
15 ENV{DM_UDEV_LOW_PRIORITY_FLAG}!="1", OPTIONS+="link_priority=50"
16
17 ENV{DM_UUID}=="*mpath-*", ENV{DM_TYPE}=="?*" \
18         SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_NAME}"
19
20 # Create persistent links for multipath tables
21 ENV{DM_WWN}=="?*", ENV{DM_PART}!="?*", \
22         SYMLINK+="disk/by-id/wwn-$env{DM_WWN}"
23
24 # Create persistent links for partitions
25 ENV{DM_WWN}=="?*", ENV{DM_PART}=="?*", \
26         SYMLINK+="disk/by-id/wwn-$env{DM_WWN}-part$env{DM_PART}"
27
28 # Create persistent by-label/by-uuid links.
29 # multipath maps with DM_NOSCAN!=1 are handled in 13-dm-disk.rules.
30 DM_UUID=="mpath-*", ENV{DM_NOSCAN}!="1", GOTO="symlink_end"
31
32 # For partitions, we don't have DM_NOSCAN.
33 # Simply load variables from db if they aren't set.
34 # 11-dm-mpath.rules does this for mpath maps.
35 # Fixme: we have currently no way to avoid calling blkid on
36 # partitions of broken mpath maps.
37 ENV{DM_UUID}!="part*-*-*", GOTO="import_end"
38 ENV{ID_FS_USAGE}!="?*", IMPORT{db}="ID_FS_USAGE"
39 ENV{ID_FS_UUID_ENC}!="?*", IMPORT{db}="ID_FS_UUID_ENC"
40 ENV{ID_FS_LABEL_ENC}!="?*", IMPORT{db}="ID_FS_LABEL_ENC"
41 ENV{ID_PART_ENTRY_NAME}!="?*", IMPORT{db}="ID_PART_ENTRY_NAME"
42 ENV{ID_PART_ENTRY_UUID}!="?*", IMPORT{db}="ID_PART_ENTRY_UUID"
43 ENV{ID_PART_ENTRY_SCHEME}!="?*", IMPORT{db}="ID_PART_ENTRY_SCHEME"
44 LABEL="import_end"
45
46 ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", \
47        SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
48 ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", \
49        SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
50 ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}"
51 ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_NAME}=="?*", \
52        SYMLINK+="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}"
53 LABEL="symlink_end"
54
55 # Create dm tables for partitions on multipath devices.
56 ENV{DM_UUID}!="mpath-?*", GOTO="mpath_kpartx_end"
57
58 # DM_SUBSYSTEM_UDEV_FLAG1 is the "skip_kpartx" flag.
59 # For events not generated by libdevmapper, we need to fetch it from db.
60 ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG1"
61 ENV{DM_SUBSYSTEM_UDEV_FLAG1}=="1", GOTO="mpath_kpartx_end"
62
63 # 11-dm-mpath.rules sets MPATH_UNCHANGED for events that can be ignored.
64 ENV{MPATH_UNCHANGED}=="1", GOTO="mpath_kpartx_end"
65
66 # Don't run kpartx now if we know it will fail or hang.
67 ENV{DM_SUSPENDED}=="1", GOTO="mpath_kpartx_end"
68 ENV{DM_NOSCAN}=="1", GOTO="mpath_kpartx_end"
69
70 # Run kpartx
71 GOTO="run_kpartx"
72 LABEL="mpath_kpartx_end"
73
74 ## Code for other subsystems (non-multipath) could be placed here ##
75
76 GOTO="kpartx_end"
77
78 LABEL="run_kpartx"
79 RUN+="/sbin/kpartx -un -p -part /dev/$name"
80
81 LABEL="kpartx_end"