2007-07-31 13:14:04 +02:00
# do not edit this file, it will be overwritten on update
2007-09-25 12:20:17 +02:00
# persistent storage links: /dev/disk/{by-id,by-uuid,by-label,by-path}
2005-09-18 04:41:09 +02:00
# scheme based on "Linux persistent device names", 2004, Hannes Reinecke <hare@suse.de>
2015-03-24 15:15:45 +01:00
ACTION=="remove", GOTO="persistent_storage_end"
2016-07-15 16:47:42 +00:00
ENV{UDEV_DISABLE_PERSISTENT_STORAGE_RULES_FLAG}=="1", GOTO="persistent_storage_end"
2015-03-24 15:15:45 +01:00
2021-07-01 12:19:57 -07:00
SUBSYSTEM!="block|ubi", GOTO="persistent_storage_end"
2019-08-16 13:37:14 +02:00
KERNEL!="loop*|mmcblk*[0-9]|msblk*[0-9]|mspblk*[0-9]|nvme*|sd*|sr*|vd*|xvd*|bcache*|cciss*|dasd*|ubd*|ubi*|scm*|pmem*|nbd*|zd*", GOTO="persistent_storage_end"
2005-09-18 04:41:09 +02:00
2007-05-16 20:15:21 +02:00
# ignore partitions that span the entire disk
2008-04-03 21:05:19 +02:00
TEST=="whole_disk", GOTO="persistent_storage_end"
2007-06-21 02:15:17 +02:00
2020-01-06 15:10:32 +08:00
# For partitions import parent disk ID_* information, except ID_FS_*.
#
# This is particularly important on media where a filesystem superblock and
# partition table are found on the same level, e.g. common Linux distro ISO
# installation media.
#
# In the case where a partition device points to the same filesystem that
# was detected on the parent disk, the ID_FS_* information is already
# present on the partition devices as well as the parent, so no need to
# propagate it. In the case where the partition device points to a different
# filesystem, merging the parent ID_FS_ properties would lead to
# inconsistencies, so we avoid doing so.
ENV{DEVTYPE}=="partition", \
IMPORT{parent}="ID_[!F]*", IMPORT{parent}="ID_", \
IMPORT{parent}="ID_F[!S]*", IMPORT{parent}="ID_F", \
IMPORT{parent}="ID_FS[!_]*", IMPORT{parent}="ID_FS"
2005-09-18 04:41:09 +02:00
2023-05-24 13:05:56 +09:00
ENV{DEVTYPE}=="partition", ENV{.PART_SUFFIX}="-part%n"
ENV{DEVTYPE}!="partition", ENV{.PART_SUFFIX}=""
2016-04-29 04:02:57 -07:00
# NVMe
2023-05-24 13:05:56 +09:00
KERNEL!="nvme*[0-9]n*[0-9]|nvme*[0-9]n*[0-9]p*[0-9]", GOTO="nvme_end"
ATTRS{serial}=="?*", ENV{ID_SERIAL_SHORT}="$attr{serial}"
ATTRS{wwid}=="?*", ENV{ID_WWN}="$attr{wwid}"
ATTRS{model}=="?*", ENV{ID_MODEL}="$attr{model}"
ATTRS{firmware_rev}=="?*", ENV{ID_REVISION}="$attr{firmware_rev}"
ATTRS{nsid}=="?*", ENV{ID_NSID}="$attr{nsid}"
ENV{ID_WWN}=="?*", SYMLINK+="disk/by-id/nvme-$env{ID_WWN}$env{.PART_SUFFIX}"
2023-04-20 21:54:59 +02:00
# obsolete symlink with non-escaped characters, kept for backward compatibility
2023-05-24 13:05:56 +09:00
ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_MODEL}!="*/*", ENV{ID_SERIAL_SHORT}!="*/*", \
ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}$env{.PART_SUFFIX}"
2023-03-02 12:06:13 +01:00
# obsolete symlink that might get overridden on adding a new nvme controller, kept for backward compatibility
2023-05-24 13:05:56 +09:00
ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", OPTIONS="string_escape=replace", \
ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}$env{.PART_SUFFIX}"
ENV{ID_MODEL}=="?*", ENV{ID_SERIAL_SHORT}=="?*", ENV{ID_NSID}=="?*", OPTIONS="string_escape=replace", \
ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}_$env{ID_NSID}", SYMLINK+="disk/by-id/nvme-$env{ID_SERIAL}$env{.PART_SUFFIX}"
LABEL="nvme_end"
2016-08-17 14:10:28 +02:00
2010-06-25 08:59:23 -05:00
# virtio-blk
2023-05-24 13:05:56 +09:00
KERNEL=="vd*", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}$env{.PART_SUFFIX}"
2010-06-25 08:59:23 -05:00
2015-03-12 15:03:30 +01:00
# ATA
2012-01-01 04:21:15 +01:00
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $devnode"
2015-03-12 15:03:30 +01:00
# ATAPI devices (SPC-3 or later)
2012-01-01 04:21:15 +01:00
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{type}=="5", ATTRS{scsi_level}=="[6-9]*", IMPORT{program}="ata_id --export $devnode"
2011-03-30 08:11:03 -04:00
# Run ata_id on non-removable USB Mass Storage (SATA/PATA disks in enclosures)
2012-01-01 04:21:15 +01:00
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", ATTR{removable}=="0", SUBSYSTEMS=="usb", IMPORT{program}="ata_id --export $devnode"
2015-03-12 15:03:30 +01:00
2022-10-30 09:43:05 +09:00
# Also import properties from usb_id for USB devices
KERNEL=="sd*[!0-9]|sr*", SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id"
2011-03-30 08:11:03 -04:00
2015-03-12 16:09:46 +01:00
# SCSI devices
2023-04-11 06:01:13 +09:00
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --allowlisted -d $devnode", ENV{ID_BUS}="scsi"
KERNEL=="cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --allowlisted -d $devnode", ENV{ID_BUS}="cciss"
2023-05-24 13:05:56 +09:00
KERNEL=="sd*|sr*|cciss*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}$env{.PART_SUFFIX}"
2022-10-30 09:43:05 +09:00
# Previously, ata_id in the above might not be able to retrieve attributes correctly,
# and properties from usb_id were used as a fallback. See issue #24921 and PR #24923.
# To keep backward compatibility, still we need to create symlinks based on USB serial.
# See issue #25179.
2023-05-24 13:05:56 +09:00
KERNEL=="sd*|sr*|cciss*", ENV{ID_USB_SERIAL}=="?*", SYMLINK+="disk/by-id/usb-$env{ID_USB_SERIAL}$env{.PART_SUFFIX}"
2005-09-18 04:41:09 +02:00
2018-07-09 15:23:25 -06:00
# PMEM devices
2023-05-24 13:05:56 +09:00
KERNEL=="pmem*", ATTRS{uuid}=="?*", SYMLINK+="disk/by-id/pmem-$attr{uuid}$env{.PART_SUFFIX}"
2018-07-09 15:23:25 -06:00
2015-03-12 16:09:46 +01:00
# FireWire
2023-05-24 13:05:56 +09:00
KERNEL=="sd*|sr*", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}$env{.PART_SUFFIX}"
2008-10-01 14:42:58 +02:00
2015-03-12 15:03:30 +01:00
# MMC
2023-08-08 14:54:05 +09:00
KERNEL=="mmcblk[0-9]|mmcblk[0-9]p[0-9]*", SUBSYSTEMS=="mmc", GOTO="mmc_start"
GOTO="mmc_end"
LABEL="mmc_start"
2023-05-24 13:05:56 +09:00
ATTRS{name}=="?*", ENV{ID_NAME}="$attr{name}"
ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}"
ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}$env{.PART_SUFFIX}"
LABEL="mmc_end"
2015-03-12 15:03:30 +01:00
# Memstick
2023-08-08 14:54:05 +09:00
KERNEL=="msblk[0-9]|mspblk[0-9]|msblk[0-9]p[0-9]|mspblk[0-9]p[0-9]", SUBSYSTEMS=="memstick", GOTO="memstick_start"
GOTO="memstick_end"
LABEL="memstick_start"
2023-05-24 13:05:56 +09:00
ATTRS{name}=="?*", ENV{ID_NAME}="$attr{name}"
ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}"
ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/memstick-$env{ID_NAME}_$env{ID_SERIAL}$env{.PART_SUFFIX}"
LABEL="memstick_end"
2008-11-19 11:24:03 +01:00
2015-03-12 15:03:30 +01:00
# by-path
2011-08-05 02:00:30 +02:00
ENV{DEVTYPE}=="disk", DEVPATH!="*/virtual/*", IMPORT{builtin}="path_id"
2022-09-21 02:26:42 +09:00
ENV{DEVTYPE}=="disk", SUBSYSTEMS=="nvme-subsystem", IMPORT{builtin}="path_id"
2023-05-02 02:28:35 +09:00
KERNEL=="mmcblk[0-9]boot[0-9]", ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-boot%n"
KERNEL=="mmcblk[0-9]boot[0-9]", ENV{DEVTYPE}=="disk", ENV{ID_PATH_WITH_USB_REVISION}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH_WITH_USB_REVISION}-boot%n"
2023-05-24 13:05:56 +09:00
KERNEL!="mmcblk[0-9]boot[0-9]", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}$env{.PART_SUFFIX}"
KERNEL!="mmcblk[0-9]boot[0-9]", ENV{ID_PATH_ATA_COMPAT}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH_ATA_COMPAT}$env{.PART_SUFFIX}"
KERNEL!="mmcblk[0-9]boot[0-9]", ENV{ID_PATH_WITH_USB_REVISION}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH_WITH_USB_REVISION}$env{.PART_SUFFIX}"
2007-06-21 02:15:17 +02:00
2017-03-01 21:30:17 +01:00
# legacy virtio-pci by-path links (deprecated)
2023-05-24 13:05:56 +09:00
KERNEL=="vd*", ENV{ID_PATH}=="pci-*", SYMLINK+="disk/by-path/virtio-$env{ID_PATH}$env{.PART_SUFFIX}"
KERNEL=="vd*", ENV{ID_PATH_WITH_USB_REVISION}=="pci-*", SYMLINK+="disk/by-path/virtio-$env{ID_PATH_WITH_USB_REVISION}$env{.PART_SUFFIX}"
2017-03-01 21:30:17 +01:00
2023-03-07 08:00:00 +00:00
{% if HAVE_BLKID %}
udev: add flag to allow disabling blkid probing
This can be useful for users of slow block devices.
For example, the persistent-storage rules are needed for USB floppy
drives be recognized by udisks2, but the extra blkid calls cause
thrashing for 25+ seconds after every disk change.
With this change, a user wishing to avoid the extra blkid invocation(s)
could create /etc/udev/rules.d/55-floppy-noprobe.rules as follows:
# Don't probe PC floppy drives
SUBSYSTEM=="block", KERNEL=="fd*", \
ENV{UDEV_DISABLE_PERSISTENT_STORAGE_BLKID_FLAG}="1"
# Don't probe USB floppy drives
SUBSYSTEM=="block", SUBSYSTEMS=="usb", \
ATTRS{bInterfaceClass}=="08", ATTRS{bInterfaceSubClass}=="04", \
ENV{UDEV_DISABLE_PERSISTENT_STORAGE_BLKID_FLAG}="1"
I didn't exclude floppies by default in this change, because floppy
devices are also emulated by some BIOSes/hypervisors in some cases, and
I don't know how many systems would fail to boot if /dev/disk/by-uuid/*
became unavailable for 'floppy disks' on those systems.
2022-07-10 21:47:45 -07:00
# allow admin to disable probing the filesystem for slow devices like floppy disk drives
ENV{UDEV_DISABLE_PERSISTENT_STORAGE_BLKID_FLAG}=="1", GOTO="persistent_storage_blkid_probe_end"
2008-08-22 10:11:34 +02:00
# probe filesystem metadata of optical drives which have a media inserted
2011-12-23 03:21:53 +01:00
KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="?*", \
udev-builtin-blkid: add support for --hint offsets
The next libblkid v2.37 is going to support session offsets for
multi-session CD/DVDs. This feature is implemented by "hint offsets".
These offsets are optional and prober specific (e.g., iso, udf, ...).
For this purpose, the library provides a new function
blkid_probe_set_hint(), and blkid(8) provides a new command-line
option --hint <name>=<offset>. For CD/DVD, the offset name is
"session_offset".
The difference between classic --offset and the new --hint is that
--offset is very restrictive and defines the probing area and the rest
of the device is invisible to the library. The new --hint works
like a suggestion, it provides a hint where the user assumes the
filesystem, but the rest of the device is still readable for the
library (for example, to get some additional superblock information
etc.).
If the --hint is without a value then it defaults to zero.
The option --hint implementation in udev-builtin-blkid.c is backwardly
compatible. If compiled against old libblkid, then the option is used in
the same way as --offset.
Addresses: https://github.com/karelzak/util-linux/issues/1161
Addresses: https://github.com/systemd/systemd/pull/17424
2020-11-30 11:38:21 +01:00
IMPORT{builtin}="blkid --hint=session_offset=$env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}"
2009-09-20 19:07:51 +02:00
# single-session CDs do not have ID_CDROM_MEDIA_SESSION_LAST_OFFSET
2011-12-23 03:21:53 +01:00
KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="", \
IMPORT{builtin}="blkid --noraid"
2008-08-22 10:11:34 +02:00
2009-02-11 21:54:43 +01:00
# probe filesystem metadata of disks
2021-02-12 19:08:28 -08:00
KERNEL!="sr*|mmcblk[0-9]boot[0-9]", IMPORT{builtin}="blkid"
2009-02-11 21:54:43 +01:00
udev: add flag to allow disabling blkid probing
This can be useful for users of slow block devices.
For example, the persistent-storage rules are needed for USB floppy
drives be recognized by udisks2, but the extra blkid calls cause
thrashing for 25+ seconds after every disk change.
With this change, a user wishing to avoid the extra blkid invocation(s)
could create /etc/udev/rules.d/55-floppy-noprobe.rules as follows:
# Don't probe PC floppy drives
SUBSYSTEM=="block", KERNEL=="fd*", \
ENV{UDEV_DISABLE_PERSISTENT_STORAGE_BLKID_FLAG}="1"
# Don't probe USB floppy drives
SUBSYSTEM=="block", SUBSYSTEMS=="usb", \
ATTRS{bInterfaceClass}=="08", ATTRS{bInterfaceSubClass}=="04", \
ENV{UDEV_DISABLE_PERSISTENT_STORAGE_BLKID_FLAG}="1"
I didn't exclude floppies by default in this change, because floppy
devices are also emulated by some BIOSes/hypervisors in some cases, and
I don't know how many systems would fail to boot if /dev/disk/by-uuid/*
became unavailable for 'floppy disks' on those systems.
2022-07-10 21:47:45 -07:00
LABEL="persistent_storage_blkid_probe_end"
2023-03-07 08:00:00 +00:00
{% endif %}
udev: add flag to allow disabling blkid probing
This can be useful for users of slow block devices.
For example, the persistent-storage rules are needed for USB floppy
drives be recognized by udisks2, but the extra blkid calls cause
thrashing for 25+ seconds after every disk change.
With this change, a user wishing to avoid the extra blkid invocation(s)
could create /etc/udev/rules.d/55-floppy-noprobe.rules as follows:
# Don't probe PC floppy drives
SUBSYSTEM=="block", KERNEL=="fd*", \
ENV{UDEV_DISABLE_PERSISTENT_STORAGE_BLKID_FLAG}="1"
# Don't probe USB floppy drives
SUBSYSTEM=="block", SUBSYSTEMS=="usb", \
ATTRS{bInterfaceClass}=="08", ATTRS{bInterfaceSubClass}=="04", \
ENV{UDEV_DISABLE_PERSISTENT_STORAGE_BLKID_FLAG}="1"
I didn't exclude floppies by default in this change, because floppy
devices are also emulated by some BIOSes/hypervisors in some cases, and
I don't know how many systems would fail to boot if /dev/disk/by-uuid/*
became unavailable for 'floppy disks' on those systems.
2022-07-10 21:47:45 -07:00
udev: decrease devlink priority for iso disks
Previously, if the priority is same, devlinks are always replaced by
newer events. The commit 331aa7aa15ee5dd12b369b276f575d521435eb52 changes
that to keep the existing devlink. That should not change any behavior
when the devices that request the same symlink do not have any
dependency, e.g. when /dev/sda1 and /dev/adb1 request the same
/dev/disk/by-label symlink, as there are no guarantee that which device
is processed first.
However, when devices has dependency, e.g. /dev/sda and /dev/sda1
request the same /dev/disk/by-label symlink, previously the symlink
always pointed to the partition, as the partition is always processed
later. But, 331aa7aa15ee5dd12b369b276f575d521435eb52 makes the symlink
point to the whole disk.
The change by 331aa7aa15ee5dd12b369b276f575d521435eb52 is crucial to
improve performance of devlink handling, especially when a system has
large number of disks with same label or so. Hence, cannot and should
not be reverted.
So, let's workaround the case, as such situation should happen only when
the disk is a hybrind ISO image, I guess.
Fixes #28468.
2023-07-21 11:39:45 +09:00
# Decrease devlink priority for whole disk of ISO hybrid images, and make the
# priority for partitions in the image relatively higher. This is for the case
# that a disk and one of its partition have the same label or so.
# See issue #28468.
ENV{ID_FS_TYPE}=="iso9660", ENV{DEVTYPE}=="disk", OPTIONS+="link_priority=-10"
2023-08-02 23:33:14 +09:00
# Decrease devlink priority for encrypted partitions, and make the priority for
# decrypted DM devices relatively higher. This is for the case that an encrypted
# partition and its decrypted DM device have the same label.
ENV{ID_FS_USAGE}=="crypto", OPTIONS+="link_priority=-10"
2008-04-20 21:15:00 +02:00
# by-label/by-uuid links (filesystem metadata)
2007-05-17 20:19:25 +02:00
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
2018-05-15 16:51:07 +02:00
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
2005-09-18 04:41:09 +02:00
2009-11-25 11:06:10 -05:00
# by-id (World Wide Name)
2023-05-24 13:05:56 +09:00
ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}$env{.PART_SUFFIX}"
2009-11-25 11:06:10 -05:00
2011-06-11 13:35:53 +02:00
# by-partlabel/by-partuuid links (partition metadata)
2016-05-09 11:24:55 +02:00
ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}"
2011-06-11 13:35:53 +02:00
ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_NAME}=="?*", SYMLINK+="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}"
2022-03-31 10:10:37 +02:00
# by-diskseq link (if an app is told to open a path like this, they may parse
# the diskseq number from the path, then issue BLKGETDISKSEQ to verify they really got
# the right device, to access specific disks in a race-free fashion)
2023-05-24 13:05:56 +09:00
ENV{DISKSEQ}=="?*", ENV{ID_IGNORE_DISKSEQ}!="1", SYMLINK+="disk/by-diskseq/$env{DISKSEQ}$env{.PART_SUFFIX}"
2022-03-31 10:10:37 +02:00
2023-07-21 10:26:13 +09:00
# Create symlinks that allow referencing loopback devices by their backing file's inode number
ENV{ID_LOOP_BACKING_DEVICE}!="", ENV{ID_LOOP_BACKING_INODE}!="", SYMLINK+="disk/by-loop-inode/$env{ID_LOOP_BACKING_DEVICE}-$env{ID_LOOP_BACKING_INODE}$env{.PART_SUFFIX}"
# Similar, but uses the .lo_file_name field of the loopback device (note that
# this is basically just a free-form string passed from userspace to the kernel
# when the device is created, it is not necessarily a file system path like the
# "loop/backing_file" sysfs attribute, which is always an absolute path)
ENV{ID_LOOP_BACKING_FILENAME_ENC}!="", SYMLINK+="disk/by-loop-ref/$env{ID_LOOP_BACKING_FILENAME_ENC}$env{.PART_SUFFIX}"
2006-03-21 16:20:54 +01:00
LABEL="persistent_storage_end"