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