udevルールがUSB3 NVMEシェルの最初のプラグインでのみ実行され、後続のプラグインでは実行されない理由がわかりません。実行すると、udevadm trigger
ルールは期待どおりに再実行されます。これらのルールの目的は、fstrim -av
廃棄コマンドを使用してデバイスをTRIMできるようにUASPモードを有効にすることです。
環境: EndeavourOS/KDE
デバイス: Sabrent RTL9210 M.2 NVME アダプタ
これは私のルールファイルです/etc/udev/rules.d/10-uas-discard.rules
。
# Turn on "unmap" mode to allow "fstrim" et al. on USB-C/NVMe adaptors
# UGreen NVMe-to-USB-C adaptor
ACTION=="add|change", ATTRS{idVendor}=="174c", ATTRS{idProduct}=="2362", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
# ID 152d:0562 JMicron Technology Corp. / JMicron USA Technology Corp. External
ACTION=="add|change", ATTRS{idVendor}=="152d", ATTRS{idProduct}=="0562", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
# ID 152d:0562 JMicron Technology Corp. / JMicron USA Technology Corp. External
ACTION=="add|change", ATTRS{idVendor}=="152d", ATTRS{idProduct}=="0583", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
# Samsung T7 Touch 1TB SSD
ACTION=="add|change", ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="4001", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
# 0bda:9210 Realtek Semiconductor Corp. RTL9210 M.2 NVME Adapter
ACTION=="add|change", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="9210", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
これをコールドスタートから接続し(ルール実行および動作する情報の削除)、プラグを抜いて再接続(存在しない情報の削除)を実行し、udevadm trigger
最後にfstrim -av
。
後続の再挿入時にこのルールが実行されない理由をご存知ですか?再挿入されたイベントログは、初期イベントログより短いように見えます。
ありがとうございます!
// first login after cold boot
[root@endeavour-p14s leeoniya]# lsblk -D
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
nvme0n1 0 512B 2T 0
├─nvme0n1p1 0 512B 2T 0
└─nvme0n1p2 0 512B 2T 0
// plugging in RTL9210 M.2 NVME Adapter
[root@endeavour-p14s leeoniya]# udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[114.149081] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1 (usb)
KERNEL[114.149734] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0 (usb)
KERNEL[114.149755] bind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1 (usb)
UDEV [114.162249] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1 (usb)
KERNEL[114.166748] add /bus/usb/drivers/usb-storage (drivers)
KERNEL[114.166764] add /module/usb_storage (module)
UDEV [114.167535] add /bus/usb/drivers/usb-storage (drivers)
UDEV [114.167709] add /module/usb_storage (module)
KERNEL[114.198213] add /devices/virtual/workqueue/scsi_tmf_0 (workqueue)
KERNEL[114.198678] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0 (scsi)
KERNEL[114.198691] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/scsi_host/host0 (scsi_host)
KERNEL[114.198706] bind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0 (usb)
KERNEL[114.198719] add /bus/usb/drivers/uas (drivers)
KERNEL[114.198734] add /module/uas (module)
UDEV [114.198855] add /devices/virtual/workqueue/scsi_tmf_0 (workqueue)
UDEV [114.199318] add /bus/usb/drivers/uas (drivers)
UDEV [114.199859] add /module/uas (module)
KERNEL[114.214531] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0 (scsi)
KERNEL[114.214553] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
KERNEL[114.214566] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device)
KERNEL[114.214590] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg)
KERNEL[114.214601] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk)
KERNEL[114.240086] add /devices/virtual/bdi/8:0 (bdi)
UDEV [114.240689] add /devices/virtual/bdi/8:0 (bdi)
KERNEL[114.305944] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda (block)
KERNEL[114.306061] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
KERNEL[114.364745] bind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
UDEV [114.365141] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0 (usb)
UDEV [114.367842] bind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1 (usb)
UDEV [114.368427] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0 (scsi)
UDEV [114.368994] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/scsi_host/host0 (scsi_host)
UDEV [114.369437] bind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0 (usb)
UDEV [114.369892] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0 (scsi)
UDEV [114.370387] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
UDEV [114.370897] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device)
UDEV [114.371184] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg)
UDEV [114.371196] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk)
UDEV [114.580606] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda (block)
UDEV [114.801345] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
UDEV [114.802293] bind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
KERNEL[114.851725] add /module/exfat (module)
UDEV [114.852153] add /module/exfat (module)
KERNEL[115.616240] change /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
UDEV [115.785530] change /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
^C
[root@endeavour-p14s leeoniya]# lsblk -D
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda 0 512B 4G 0 <--- DISC-GRAN 512B
└─sda1 0 512B 4G 0 <--- DISC-GRAN 512B
nvme0n1 0 512B 2T 0
├─nvme0n1p1 0 512B 2T 0
└─nvme0n1p2 0 512B 2T 0
// unplugging RTL9210 M.2 NVME Adapter
[root@endeavour-p14s leeoniya]# udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[588.828217] change /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
UDEV [589.386110] change /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
KERNEL[589.415468] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg)
KERNEL[589.415494] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device)
KERNEL[589.415505] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk)
KERNEL[589.415672] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
KERNEL[589.415719] remove /devices/virtual/bdi/8:0 (bdi)
KERNEL[589.415896] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda (block)
UDEV [589.416517] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg)
UDEV [589.417077] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device)
UDEV [589.417282] remove /devices/virtual/bdi/8:0 (bdi)
UDEV [589.417298] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk)
UDEV [589.417456] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
UDEV [589.418027] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda (block)
KERNEL[589.669806] unbind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
KERNEL[589.669869] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
KERNEL[589.669930] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0 (scsi)
KERNEL[589.670113] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/scsi_host/host0 (scsi_host)
KERNEL[589.670149] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0 (scsi)
UDEV [589.671366] unbind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
UDEV [589.671385] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/scsi_host/host0 (scsi_host)
UDEV [589.671727] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
UDEV [589.672009] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0 (scsi)
UDEV [589.672278] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0 (scsi)
KERNEL[589.696497] remove /devices/virtual/workqueue/scsi_tmf_0 (workqueue)
KERNEL[589.696756] unbind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0 (usb)
KERNEL[589.696800] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0 (usb)
UDEV [589.697326] remove /devices/virtual/workqueue/scsi_tmf_0 (workqueue)
UDEV [589.697749] unbind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0 (usb)
UDEV [589.698070] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0 (usb)
KERNEL[589.703445] unbind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1 (usb)
KERNEL[589.703492] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1 (usb)
UDEV [589.705078] unbind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1 (usb)
UDEV [589.705646] remove /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1 (usb)
KERNEL[602.922604] change /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:37/PNP0C09:00/ACPI0003:00/power_supply/AC (power_supply)
UDEV [602.926982] change /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:37/PNP0C09:00/ACPI0003:00/power_supply/AC (power_supply)
^C
[root@endeavour-p14s leeoniya]# lsblk -D
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
nvme0n1 0 512B 2T 0
├─nvme0n1p1 0 512B 2T 0
└─nvme0n1p2 0 512B 2T 0
// re-plugging RTL9210 M.2 NVME Adapter
[root@endeavour-p14s leeoniya]# udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[686.411970] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1 (usb)
KERNEL[686.413054] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0 (usb)
KERNEL[686.443125] add /devices/virtual/workqueue/scsi_tmf_0 (workqueue)
KERNEL[686.443242] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:[root@endeavour-p14s leeoniya]#1.0/host0 (scsi)
KERNEL[686.443251] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/scsi_host/host0 (scsi_host)
KERNEL[686.443260] bind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0 (usb)
KERNEL[686.443271] bind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1 (usb)
UDEV [686.444070] add /devices/virtual/workqueue/scsi_tmf_0 (workqueue)
UDEV [686.446323] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1 (usb)
UDEV [686.447259] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0 (usb)
UDEV [686.447828] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0 (scsi)
UDEV [686.448445] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/scsi_host/host0 (scsi_host)
UDEV [686.448982] bind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0 (usb)
UDEV [686.450968] bind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1 (usb)
KERNEL[686.459234] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0 (scsi)
KERNEL[686.459266] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
KERNEL[686.459275] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device)
KERNEL[686.459360] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg)
KERNEL[686.459378] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk)
UDEV [686.460296] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0 (scsi)
UDEV [686.460790] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
UDEV [686.461314] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device)
UDEV [686.461567] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg)
UDEV [686.461987] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk)
KERNEL[686.484506] add /devices/virtual/bdi/8:0 (bdi)
UDEV [686.484960] add /devices/virtual/bdi/8:0 (bdi)
KERNEL[686.548957] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda (block)
KERNEL[686.549011] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
KERNEL[686.631648] bind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
UDEV [686.809723] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda (block)
UDEV [687.031650] add /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
UDEV [687.032506] bind /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0 (scsi)
KERNEL[687.810280] change /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
UDEV [687.979196] change /devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-1/6-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
^C
[root@endeavour-p14s leeoniya]# lsblk -D
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda 0 0B 4G 0 <--- DISC-GRAN 0B ??
└─sda1 0 0B 4G 0 <--- DISC-GRAN 0B ??
nvme0n1 0 512B 2T 0
├─nvme0n1p1 0 512B 2T 0
└─nvme0n1p2 0 512B 2T 0
[root@endeavour-p14s leeoniya]# udevadm trigger <--- re-trigger
[root@endeavour-p14s leeoniya]# lsblk -D
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda 0 512B 4G 0 <--- DISC-GRAN 512B
└─sda1 0 512B 4G 0 <--- DISC-GRAN 512B
nvme0n1 0 512B 2T 0
├─nvme0n1p1 0 512B 2T 0
└─nvme0n1p2 0 512B 2T 0
[root@endeavour-p14s leeoniya]# fstrim -av
/run/media/leeoniya/NVME: 893.7 GiB (959619530752 bytes) trimmed on /dev/sda1
/boot/efi: 266.5 MiB (279408640 bytes) trimmed on /dev/nvme0n1p1
/: 908.5 GiB (975523504128 bytes) trimmed on /dev/nvme0n1p2