]> git.ipfire.org Git - thirdparty/systemd.git/blame - rules/60-persistent-storage.rules
rules: storage - whitelist partitioned MS & MMC devices
[thirdparty/systemd.git] / rules / 60-persistent-storage.rules
CommitLineData
4beaed36
KS
1# do not edit this file, it will be overwritten on update
2
31150fbb 3# persistent storage links: /dev/disk/{by-id,by-uuid,by-label,by-path}
a3f129d0
KS
4# scheme based on "Linux persistent device names", 2004, Hannes Reinecke <hare@suse.de>
5
c6e20ceb
TG
6ACTION=="remove", GOTO="persistent_storage_end"
7
ad9deeeb 8SUBSYSTEM!="block", GOTO="persistent_storage_end"
174470fb 9KERNEL!="loop*|mmcblk*[0-9]|mspblk*[0-9]|nvme*|sd*|sr*|vd*", GOTO="persistent_storage_end"
a3f129d0 10
51b5c5f8 11# ignore partitions that span the entire disk
1ed38f41 12TEST=="whole_disk", GOTO="persistent_storage_end"
f809fdff 13
aeaf0fdd 14# for partitions import parent information
f809fdff 15ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*"
a3f129d0 16
2d000ed9
RH
17# virtio-blk
18KERNEL=="vd*[!0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}"
19KERNEL=="vd*[0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}-part%n"
20
1aff2068 21# ATA
220893b3 22KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $devnode"
1aff2068
KS
23
24# ATAPI devices (SPC-3 or later)
220893b3 25KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{type}=="5", ATTRS{scsi_level}=="[6-9]*", IMPORT{program}="ata_id --export $devnode"
42b9482a
DZ
26
27# Run ata_id on non-removable USB Mass Storage (SATA/PATA disks in enclosures)
220893b3 28KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", ATTR{removable}=="0", SUBSYSTEMS=="usb", IMPORT{program}="ata_id --export $devnode"
1aff2068
KS
29
30# Fall back usb_id for USB devices
d7867b31 31KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id"
42b9482a 32
52346b5f 33# SCSI devices
220893b3 34KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $devnode", ENV{ID_BUS}="scsi"
1aff2068
KS
35KERNEL=="sd*|sr*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
36KERNEL=="sd*", ENV{DEVTYPE}=="partition", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n"
a3f129d0 37
52346b5f 38# FireWire
333b736f
KS
39KERNEL=="sd*[!0-9]|sr*", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}"
40KERNEL=="sd*[0-9]", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}-part%n"
41
1aff2068
KS
42# MMC
43KERNEL=="mmcblk[0-9]", SUBSYSTEMS=="mmc", ATTRS{name}=="?*", ATTRS{serial}=="?*", \
44 ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}"
f809fdff 45KERNEL=="mmcblk[0-9]p[0-9]", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}-part%n"
1aff2068
KS
46
47# Memstick
48KERNEL=="mspblk[0-9]", SUBSYSTEMS=="memstick", ATTRS{name}=="?*", ATTRS{serial}=="?*", \
49 ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/memstick-$env{ID_NAME}_$env{ID_SERIAL}"
15b3df55
HH
50KERNEL=="mspblk[0-9]p[0-9]", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/memstick-$env{ID_NAME}_$env{ID_SERIAL}-part%n"
51
1aff2068 52# by-path
d7867b31 53ENV{DEVTYPE}=="disk", DEVPATH!="*/virtual/*", IMPORT{builtin}="path_id"
0c13be38 54ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}"
f809fdff 55ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"
f809fdff 56
8eb4ab83 57# probe filesystem metadata of optical drives which have a media inserted
7c2dee4a
KS
58KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="?*", \
59 IMPORT{builtin}="blkid --offset=$env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}"
ce096702 60# single-session CDs do not have ID_CDROM_MEDIA_SESSION_LAST_OFFSET
7c2dee4a
KS
61KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="", \
62 IMPORT{builtin}="blkid --noraid"
8eb4ab83 63
88ec7bb7 64# probe filesystem metadata of disks
7c2dee4a 65KERNEL!="sr*", IMPORT{builtin}="blkid"
88ec7bb7 66
41677cf5 67# by-label/by-uuid links (filesystem metadata)
9e23328e
KS
68ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
69ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
a3f129d0 70
28c74639 71# by-id (World Wide Name)
7f4954d0
DZ
72ENV{DEVTYPE}=="disk", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}"
73ENV{DEVTYPE}=="partition", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}-part%n"
28c74639 74
693b6344
K
75# by-partlabel/by-partuuid links (partition metadata)
76ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}"
77ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_NAME}=="?*", SYMLINK+="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}"
78
329f7803 79# add symlink to GPT root disk
98b2f766 80ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_GPT_AUTO_ROOT}=="1", SYMLINK+="gpt-auto-root"
329f7803 81
ad9deeeb 82LABEL="persistent_storage_end"