aboutsummaryrefslogtreecommitdiff
path: root/scripts/54-before-scsi-sg3_id.rules
blob: bb36650a6a471395dbefd8381f7227ce89a1cd36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# do not edit this file, it will be overwritten on update

# persistent storage links: /dev/disk/{by-id,by-path}
# scheme based on "Linux persistent device names", 2004, Hannes Reinecke <hare@suse.de>

# This file contains rules for setting udev environment variables based on
# hardware properties (serial numbers etc), which can be obtained without
# actually reading from the device.
#
# Hopefully this will be integrated into systemd/udev soon (as 54-storage-hardware.rules).
# Until then, we ship it here in sg3-utils.
# It's important that rules dealing with low-level hardware attributes run
# before the generic SCSI rules in 55-scsi-sg3_utils.rules.

ACTION=="remove", GOTO="storage_hardware_end"
SUBSYSTEM!="block", GOTO="block_storage_end"
KERNEL!="sd*|sr*|cciss*", GOTO="block_storage_end"

# ignore partitions that span the entire disk
TEST=="whole_disk", GOTO="block_storage_end"

# for partitions import parent information
ENV{DEVTYPE}=="partition", ENV{ID_SERIAL}!="?*", IMPORT{parent}="ID_*"

# ATA
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $devnode"

# ATAPI devices (SPC-3 or later)
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{type}=="5", ATTRS{scsi_level}=="[6-9]*", IMPORT{program}="ata_id --export $devnode"

# Run ata_id on non-removable USB Mass Storage (SATA/PATA disks in enclosures)
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", ATTR{removable}=="0", SUBSYSTEMS=="usb", IMPORT{program}="ata_id --export $devnode"

# Fall back usb_id for USB devices
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id"

# FireWire
ENV{ID_IEEE1394}!="?*", KERNEL=="sd*|sr*", ATTRS{ieee1394_id}=="?*", ENV{ID_IEEE1394}="$attr{ieee1394_id}"

# by-path
ENV{ID_PATH}!="?*", ENV{DEVTYPE}=="disk", DEVPATH!="*/virtual/*", IMPORT{builtin}="path_id"

LABEL="block_storage_end"

# SCSI tape devices
SUBSYSTEM!="scsi_tape", GOTO="storage_hardware_end"
KERNEL!="st*[0-9]|nst*[0-9]", GOTO="storage_hardware_end"

ENV{ID_SERIAL}!="?*", ATTRS{ieee1394_id}=="?*", ENV{ID_SERIAL}="$attr{ieee1394_id}", ENV{ID_BUS}="ieee1394"
ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", ATTRS{serial}=="?*", IMPORT{builtin}="usb_id"

# by-path
ENV{ID_PATH}!="?*", IMPORT{builtin}="path_id"

LABEL="storage_hardware_end"