chiark / gitweb /
65e7204531d7e640f370a364a39bd6fda2923173
[elogind.git] / rules / debian / 60-persistent-storage.rules
1 # This file contains the rules needed to create persistent device names.
2
3 # forward scsi device events to the corresponding block device
4 ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", \
5         TEST=="block",                  ATTR{block/*/uevent}="change"
6
7 # we are only interested in add and change actions for block devices
8 ACTION!="add|change",                   GOTO="persistent_storage_end"
9 SUBSYSTEM!="block",                     GOTO="persistent_storage_end"
10
11 # and we can safely ignore these kinds of devices
12 KERNEL=="ram*|loop*|fd*|nbd*|gnbd*|dm-*|md*", GOTO="persistent_storage_end"
13
14 # skip removable ide devices, because open(2) on them causes an events loop
15 KERNEL=="hd*[!0-9]", ATTR{removable}=="1", DRIVERS=="ide-cs|ide-floppy", \
16                                         GOTO="persistent_storage_end"
17 KERNEL=="hd*[0-9]", ATTRS{removable}=="1", \
18                                         GOTO="persistent_storage_end"
19
20 # ignore partitions that span the entire disk
21 TEST=="whole_disk",                     GOTO="persistent_storage_end"
22
23 # skip xen virtual hard disks
24 DRIVERS=="vbd",                         GOTO="no_hardware_id"
25
26 # check these attributes of /sys/class/block nodes
27 ENV{DEVTYPE}!="?*", ATTR{range}=="?*",  ENV{DEVTYPE}="disk"
28 ENV{DEVTYPE}!="?*", ATTR{start}=="?*",  ENV{DEVTYPE}="partition"
29
30 # look for different kinds of unique identificators
31 KERNEL=="hd*[!0-9]", \
32         IMPORT{program}="ata_id --export $tempnode"
33
34 KERNEL=="sd*[!0-9]|sr*",                ATTRS{ieee1394_id}=="?*", \
35         ENV{ID_BUS}="ieee1394", ENV{ID_SERIAL}="$attr{ieee1394_id}"
36 KERNEL=="sd*[!0-9]|sr*",                ENV{ID_SERIAL}!="?*", \
37         SUBSYSTEMS=="usb", \
38         IMPORT{program}="usb_id --export $devpath"
39 KERNEL=="sd*[!0-9]|sr*",                ENV{ID_SERIAL}!="?*", \
40         ENV{ID_BUS}="scsi", \
41         IMPORT{program}="scsi_id --export --whitelisted --device=$tempnode"
42 KERNEL=="cciss?c[0-9]d[0-9]*",          ENV{ID_SERIAL}!="?*", \
43         ENV{ID_BUS}="cciss", \
44         IMPORT{program}="scsi_id --export --whitelisted --device=$tempnode"
45
46 KERNEL=="dasd*[!0-9]", \
47         IMPORT{program}="dasd_id --export $tempnode"
48
49 KERNEL=="sd*[!0-9]|hd*[!0-9]", \
50         IMPORT{program}="edd_id --export $tempnode"
51
52 KERNEL=="sd*[!0-9]|sr*",                ENV{ID_VENDOR}=="ATA", \
53         PROGRAM="ata_id $tempnode", RESULT=="?*", ENV{ID_ATA_COMPAT}="$result"
54
55 # find the physical path of the device
56 ENV{DEVTYPE}=="disk",                   IMPORT{program}="path_id $devpath"
57
58 LABEL="no_hardware_id"
59
60 # import the variables of partitions from the parent disks
61 ENV{DEVTYPE}=="partition",              IMPORT{parent}="ID_*"
62
63 # obsolete PATA driver
64 KERNEL=="hd*[!0-9]",                    ENV{ID_SERIAL}=="?*", \
65         SYMLINK+="disk/by-id/ata-$env{ID_MODEL}_$env{ID_SERIAL}"
66 KERNEL=="hd*[0-9]",                     ENV{ID_SERIAL}=="?*", \
67         SYMLINK+="disk/by-id/ata-$env{ID_MODEL}_$env{ID_SERIAL}-part%n"
68 # hd*-like compatibility links for libata and PATA devices
69 KERNEL=="sd*[!0-9]|sr*",                ENV{ID_ATA_COMPAT}=="?*", \
70         SYMLINK+="disk/by-id/ata-$env{ID_ATA_COMPAT}"
71 KERNEL=="sd*[0-9]",                     ENV{ID_ATA_COMPAT}=="?*", \
72         SYMLINK+="disk/by-id/ata-$env{ID_ATA_COMPAT}-part%n"
73
74 KERNEL=="mmcblk[0-9]", ATTR{name}=="?*", ATTR{serial}=="?*", \
75         ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", \
76         SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}"
77 KERNEL=="mmcblk[0-9]p[0-9]", ATTR{name}=="?*", ATTR{serial}=="?*", \
78         ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", \
79         SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}-part%n"
80
81 ENV{DEVTYPE}=="disk",                   ENV{ID_EDD}=="?*", \
82         SYMLINK+="disk/by-id/edd-$env{ID_EDD}"
83 ENV{DEVTYPE}=="partition",              ENV{ID_EDD}=="?*", \
84         SYMLINK+="disk/by-id/edd-$env{ID_EDD}-part%n"
85
86 KERNEL=="sd*[!0-9]|sr*|dasd[!0-9]*|cciss?c[0-9]d[0-9]*", ENV{ID_SERIAL}=="?*", \
87         SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
88 KERNEL=="sd*[0-9]|dasd*[0-9]|cciss*p[0-9]*",            ENV{ID_SERIAL}=="?*", \
89         SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n"
90
91 ENV{DEVTYPE}=="disk",                   ENV{ID_PATH}=="?*", \
92         SYMLINK+="disk/by-path/$env{ID_PATH}"
93 ENV{DEVTYPE}=="partition",              ENV{ID_PATH}=="?*", \
94         SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"
95
96 # skip unpartitioned removable media devices from drivers which do not send
97 # "change" events
98 ENV{DEVTYPE}=="disk", KERNEL!="sd*|sr*", ATTR{removable}=="1", \
99                                         GOTO="persistent_storage_end"
100
101 # UUID and volume label
102 IMPORT{program}="vol_id --export $tempnode"
103 ENV{ID_FS_UUID_ENC}=="?*",      ENV{ID_FS_USAGE}=="filesystem|other|crypto", \
104         SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
105 ENV{ID_FS_LABEL_ENC}=="?*",     ENV{ID_FS_USAGE}=="filesystem|other", \
106         SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
107
108 LABEL="persistent_storage_end"
109