mirror of
https://github.com/systemd/systemd.git
synced 2024-11-05 15:21:37 +03:00
42b9482ab2
If a USB device is marked as removable, it is often a SATA/PATA disk in an enclosure (note that flash card readers and usb storage sticks are always marked as removable). In this case, try running ata_id (which sends ATA commands wrapped in SCSI ATA PASS THROUGH commands) to get information about the disk. If this fails, just fall back to running usb_id since it could be the device isn't an ATA device at all or the device doesn't have a SAT layer. This extra information is nice to have as it indicates if it is suitable to send e.g. SMART commands to the disk, whether the disk supports power management and so on. Additionally, the VPD and serial number returned by ata_id is usually more accurate as it stems from the disk itself instead of the enclosure. Note that udisks has been doing this for a while KERNEL=="sd*[!0-9]", ATTR{removable}=="0", ENV{ID_BUS}=="usb", ENV{DEVTYPE}=="disk", IMPORT{program}="udisks-probe-ata-smart $tempnode" so this change shouldn't be too disruptive (udisks-probe-ata-smart also sends ATA commands via the ATA PASS THROUGH command). Signed-off-by: David Zeuthen <davidz@redhat.com>
84 lines
5.4 KiB
Plaintext
84 lines
5.4 KiB
Plaintext
# do not edit this file, it will be overwritten on update
|
|
|
|
# persistent storage links: /dev/disk/{by-id,by-uuid,by-label,by-path}
|
|
# scheme based on "Linux persistent device names", 2004, Hannes Reinecke <hare@suse.de>
|
|
|
|
# forward scsi device event to corresponding block device
|
|
ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", TEST=="block", ATTR{block/*/uevent}="change"
|
|
|
|
ACTION=="remove", GOTO="persistent_storage_end"
|
|
SUBSYSTEM!="block", GOTO="persistent_storage_end"
|
|
|
|
# skip rules for inappropriate block devices
|
|
KERNEL=="fd*|mtd*|nbd*|gnbd*|btibm*|dm-*|md*", GOTO="persistent_storage_end"
|
|
|
|
# ignore partitions that span the entire disk
|
|
TEST=="whole_disk", GOTO="persistent_storage_end"
|
|
|
|
# for partitions import parent information
|
|
ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*"
|
|
|
|
# virtio-blk
|
|
KERNEL=="vd*[!0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}"
|
|
KERNEL=="vd*[0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}-part%n"
|
|
|
|
# ATA devices with their own "ata" kernel subsystem
|
|
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="ata", IMPORT{program}="ata_id --export $tempnode"
|
|
# ATA devices using the "scsi" subsystem
|
|
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $tempnode"
|
|
# ATA/ATAPI devices (SPC-3 or later) using the "scsi" subsystem
|
|
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{type}=="5", ATTRS{scsi_level}=="[6-9]*", IMPORT{program}="ata_id --export $tempnode"
|
|
|
|
# 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 $tempnode"
|
|
# Otherwise fall back to using usb_id for USB devices
|
|
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", IMPORT{program}="usb_id --export %p"
|
|
|
|
# scsi devices
|
|
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $tempnode", ENV{ID_BUS}="scsi"
|
|
KERNEL=="cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $tempnode", ENV{ID_BUS}="cciss"
|
|
KERNEL=="sd*|sr*|cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
|
|
KERNEL=="sd*|cciss*", ENV{DEVTYPE}=="partition", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n"
|
|
|
|
# firewire
|
|
KERNEL=="sd*[!0-9]|sr*", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}"
|
|
KERNEL=="sd*[0-9]", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}-part%n"
|
|
|
|
# scsi compat links for ATA devices
|
|
KERNEL=="sd*[!0-9]", ENV{ID_BUS}=="ata", PROGRAM="scsi_id --whitelisted --replace-whitespace -p0x80 -d$tempnode", RESULT=="?*", ENV{ID_SCSI_COMPAT}="$result", SYMLINK+="disk/by-id/scsi-$env{ID_SCSI_COMPAT}"
|
|
KERNEL=="sd*[0-9]", ENV{ID_SCSI_COMPAT}=="?*", SYMLINK+="disk/by-id/scsi-$env{ID_SCSI_COMPAT}-part%n"
|
|
|
|
KERNEL=="mmcblk[0-9]", SUBSYSTEMS=="mmc", ATTRS{name}=="?*", ATTRS{serial}=="?*", ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}"
|
|
KERNEL=="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"
|
|
KERNEL=="mspblk[0-9]", SUBSYSTEMS=="memstick", ATTRS{name}=="?*", ATTRS{serial}=="?*", ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/memstick-$env{ID_NAME}_$env{ID_SERIAL}"
|
|
KERNEL=="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"
|
|
|
|
# by-path (parent device path)
|
|
ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="", DEVPATH!="*/virtual/*", IMPORT{program}="path_id %p"
|
|
ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}"
|
|
ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"
|
|
|
|
# skip unpartitioned removable media devices from drivers which do not send "change" events
|
|
ENV{DEVTYPE}=="disk", KERNEL!="sd*|sr*", ATTR{removable}=="1", GOTO="persistent_storage_end"
|
|
|
|
# probe filesystem metadata of optical drives which have a media inserted
|
|
KERNEL=="sr*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="?*", IMPORT{program}="/sbin/blkid -o udev -p -u noraid -O $env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET} $tempnode"
|
|
# single-session CDs do not have ID_CDROM_MEDIA_SESSION_LAST_OFFSET
|
|
KERNEL=="sr*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="", IMPORT{program}="/sbin/blkid -o udev -p -u noraid $tempnode"
|
|
|
|
# probe filesystem metadata of disks
|
|
KERNEL!="sr*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
|
|
|
|
# watch for future changes
|
|
KERNEL!="sr*", OPTIONS+="watch"
|
|
|
|
# by-label/by-uuid links (filesystem metadata)
|
|
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
|
|
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
|
|
|
|
# by-id (World Wide Name)
|
|
ENV{DEVTYPE}=="disk", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}"
|
|
ENV{DEVTYPE}=="partition", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}-part%n"
|
|
|
|
LABEL="persistent_storage_end"
|