HDD 연결이 끊어졌을 때 bash 스크립트를 시작하는 udev 규칙에 문제가 있습니다.

HDD 연결이 끊어졌을 때 bash 스크립트를 시작하는 udev 규칙에 문제가 있습니다.

어떤 이유로 인해 HDD 연결이 끊어지면 udev 규칙을 사용하여 Raspberry Pi(Debian Jessie 실행)가 Pushbullet에 푸시 알림을 보내도록 하려고 합니다. 이제 나는 이 일을 성공적으로 해냈습니다. 그러나 문제는 스크립트가 한 번이 아닌 14번 실행되고 연결 해제 및 연결 작업 시 실행된다는 점입니다. 이는 제 의도가 아닙니다.

다음과 같이 다양한 규칙 파일 구성을 시도했습니다.

ACTION==”remove”,
KERNEL==”sda1”,
SUBSYSTEM==”block”,
KERNELS==”1-1.2”,
SUBSYSTEMS==”usb”,
ATTRS{idProduct}==”10a2”,
ATTRS{idVendor}==”1058”,
ATTRS{manufacturer}=="Western Digital",
RUN+="/home/pi/HDD_removed.sh"

그리고

ACTION=="remove",
ENV{ID_MODEL}=="Elements_10A2",
RUN+="/home/pi/HDD_removed.sh"

그리고 다른 것들은 아무것도 잘 작동하지 않습니다 ..

도움을 주기 위해 아래 udevadm info 및 udevadm Monitor의 출력을 인쇄했습니다(크기가 작아서 죄송합니다...).

$ udevadm 정보 -a -p $(udevadm 정보 -q 경로 -n /dev/sda1)

looking at device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1':
KERNEL=="sda1"
SUBSYSTEM=="block"
DRIVER==""
ATTR{start}=="2048"
ATTR{inflight}=="       0        0"
ATTR{ro}=="0"
ATTR{partition}=="1"
ATTR{stat}=="     545        0    61544     4110        0        0        0        0        0     1320     4110"
ATTR{size}=="1953456128"
ATTR{alignment_offset}=="0"
ATTR{discard_alignment}=="0"

looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/block/sda':
KERNELS=="sda"
SUBSYSTEMS=="block"
DRIVERS==""
ATTRS{badblocks}==""
ATTRS{range}=="16"
ATTRS{capability}=="50"
ATTRS{inflight}=="       0        0"
ATTRS{ext_range}=="256"
ATTRS{ro}=="0"
ATTRS{stat}=="     590        0    62336     4140        0        0        0        0        0     1350     4140"
ATTRS{events_poll_msecs}=="-1"
ATTRS{events_async}==""
ATTRS{removable}=="0"
ATTRS{size}=="1953458176"
ATTRS{events}==""
ATTRS{alignment_offset}=="0"
ATTRS{discard_alignment}=="0"

looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0':
KERNELS=="0:0:0:0"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRS{evt_soft_threshold_reached}=="0"
ATTRS{evt_mode_parameter_change_reported}=="0"
ATTRS{inquiry}==""
ATTRS{evt_capacity_change_reported}=="0"
ATTRS{vendor}=="WD      "
ATTRS{timeout}=="30"
ATTRS{evt_lun_change_reported}=="0"
ATTRS{evt_media_change}=="0"
ATTRS{queue_type}=="none"
ATTRS{device_busy}=="0"
ATTRS{eh_timeout}=="10"
ATTRS{model}=="Elements 10A2   "
ATTRS{iocounterbits}=="32"
ATTRS{queue_depth}=="1"
ATTRS{type}=="0"
ATTRS{evt_inquiry_change_reported}=="0"
ATTRS{max_sectors}=="240"
ATTRS{iodone_cnt}=="0x27d"
ATTRS{state}=="running"
ATTRS{iorequest_cnt}=="0x27d"
ATTRS{rev}=="1033"
ATTRS{ioerr_cnt}=="0x3"
ATTRS{scsi_level}=="7"
ATTRS{device_blocked}=="0"

looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0':
KERNELS=="target0:0:0"
SUBSYSTEMS=="scsi"
DRIVERS==""

looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0':
KERNELS=="host0"
SUBSYSTEMS=="scsi"
DRIVERS==""

looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0':
KERNELS=="1-1.2:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="usb-storage"
ATTRS{bInterfaceProtocol}=="50"
ATTRS{bInterfaceNumber}=="00"
ATTRS{bInterfaceSubClass}=="06"
ATTRS{bInterfaceClass}=="08"
ATTRS{bAlternateSetting}==" 0"
ATTRS{authorized}=="1"
ATTRS{bNumEndpoints}=="02"
ATTRS{supports_autosuspend}=="1"

looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2':
KERNELS=="1-1.2"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceClass}=="00"
ATTRS{manufacturer}=="Western Digital"
ATTRS{bmAttributes}=="80"
ATTRS{bConfigurationValue}=="1"
ATTRS{version}==" 2.10"
ATTRS{devnum}=="9"
ATTRS{bMaxPower}=="100mA"
ATTRS{idProduct}=="10a2"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{urbnum}=="7168"
ATTRS{bDeviceSubClass}=="00"
ATTRS{maxchild}=="0"
ATTRS{bcdDevice}=="1033"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{idVendor}=="1058"
ATTRS{product}=="Elements 10A2"
ATTRS{speed}=="480"
ATTRS{removable}=="removable"
ATTRS{ltm_capable}=="no"
ATTRS{serial}=="575831314541323038393032"
ATTRS{bNumConfigurations}=="1"
ATTRS{busnum}=="1"
ATTRS{authorized}=="1"
ATTRS{quirks}=="0x0"
ATTRS{configuration}==""
ATTRS{devpath}=="1.2"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bNumInterfaces}==" 1"

looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1':
KERNELS=="1-1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceClass}=="09"
ATTRS{bmAttributes}=="e0"
ATTRS{bConfigurationValue}=="1"
ATTRS{version}==" 2.00"
ATTRS{devnum}=="2"
ATTRS{bMaxPower}=="2mA"
ATTRS{idProduct}=="9514"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{urbnum}=="144"
ATTRS{bDeviceSubClass}=="00"
ATTRS{maxchild}=="5"
ATTRS{bcdDevice}=="0200"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{idVendor}=="0424"
ATTRS{speed}=="480"
ATTRS{removable}=="unknown"
ATTRS{ltm_capable}=="no"
ATTRS{bNumConfigurations}=="1"
ATTRS{busnum}=="1"
ATTRS{authorized}=="1"
ATTRS{quirks}=="0x0"
ATTRS{configuration}==""
ATTRS{devpath}=="1"
ATTRS{bDeviceProtocol}=="02"
ATTRS{bNumInterfaces}==" 1"

looking at parent device '/devices/platform/soc/3f980000.usb/usb1':
KERNELS=="usb1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceClass}=="09"
ATTRS{manufacturer}=="Linux 4.9.24-v7+ dwc_otg_hcd"
ATTRS{bmAttributes}=="e0"
ATTRS{bConfigurationValue}=="1"
ATTRS{version}==" 2.00"
ATTRS{devnum}=="1"
ATTRS{bMaxPower}=="0mA"
ATTRS{idProduct}=="0002"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{urbnum}=="25"
ATTRS{bDeviceSubClass}=="00"
ATTRS{maxchild}=="1"
ATTRS{bcdDevice}=="0409"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{idVendor}=="1d6b"
ATTRS{product}=="DWC OTG Controller"
ATTRS{speed}=="480"
ATTRS{authorized_default}=="1"
ATTRS{interface_authorized_default}=="1"
ATTRS{removable}=="unknown"
ATTRS{ltm_capable}=="no"
ATTRS{serial}=="3f980000.usb"
ATTRS{bNumConfigurations}=="1"
ATTRS{busnum}=="1"
ATTRS{authorized}=="1"
ATTRS{quirks}=="0x0"
ATTRS{configuration}==""
ATTRS{devpath}=="0"
ATTRS{bDeviceProtocol}=="01"
ATTRS{bNumInterfaces}==" 1"

looking at parent device '/devices/platform/soc/3f980000.usb':
KERNELS=="3f980000.usb"
SUBSYSTEMS=="platform"
DRIVERS=="dwc_otg"
ATTRS{wr_reg_test}=="Time to write GNPTXFSIZ reg 10000000 times: 540 msecs (54 jiffies)"
ATTRS{grxfsiz}=="GRXFSIZ = 0x00000306"
ATTRS{srpcapable}=="SRPCapable = 0x1"
ATTRS{buspower}=="Bus Power = 0x1"
ATTRS{bussuspend}=="Bus Suspend = 0x0"
ATTRS{hptxfsiz}=="HPTXFSIZ = 0x02000406"
ATTRS{hnp}=="HstNegScs = 0x0"
ATTRS{mode}=="Mode = 0x1"
ATTRS{mode_ch_tim_en}=="Mode Change Ready Timer Enable = 0x0"
ATTRS{hsic_connect}=="HSIC Connect = 0x1"
ATTRS{gsnpsid}=="GSNPSID = 0x4f54280a"
ATTRS{driver_override}=="(null)"
ATTRS{hcd_frrem}=="HCD Dump Frame Remaining"
ATTRS{gotgctl}=="GOTGCTL = 0x001c0001"
ATTRS{gpvndctl}=="GPVNDCTL = 0x00000000"
ATTRS{hnpcapable}=="HNPCapable = 0x1"
ATTRS{spramdump}=="SPRAM Dump"
ATTRS{regoffset}=="0xffffffff"
ATTRS{gnptxfsiz}=="GNPTXFSIZ = 0x01000306"
ATTRS{guid}=="GUID = 0x2708a000"
ATTRS{regdump}=="Register Dump"
ATTRS{hprt0}=="HPRT0 = 0x00001405"
ATTRS{hcddump}=="HCD Dump"
ATTRS{rem_wakeup_pwrdn}==""
ATTRS{regvalue}=="invalid offset"
ATTRS{gusbcfg}=="GUSBCFG = 0x20001700"
ATTRS{fr_interval}=="Frame Interval = 0x1d4b"
ATTRS{busconnected}=="Bus Connected = 0x1"
ATTRS{remote_wakeup}=="Remote Wakeup Sig = 0 Enabled = 0 LPM Remote Wakeup = 0"
ATTRS{devspeed}=="Device Speed = 0x0"
ATTRS{rd_reg_test}=="Time to read GNPTXFSIZ reg 10000000 times: 1500 msecs (150 jiffies)"
ATTRS{enumspeed}=="Device Enumeration Speed = 0x1"
ATTRS{inv_sel_hsic}=="Invert Select HSIC = 0x0"
ATTRS{ggpio}=="GGPIO = 0x00000000"
ATTRS{srp}=="SesReqScs = 0x1"

looking at parent device '/devices/platform/soc':
KERNELS=="soc"
SUBSYSTEMS=="platform"
DRIVERS==""
ATTRS{driver_override}=="(null)"

looking at parent device '/devices/platform':
KERNELS=="platform"
SUBSYSTEMS==""
DRIVERS==""

$ udevadm 모니터 --속성

KERNEL[50982.358011] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg)
ACTION=remove
DEVNAME=/dev/bsg/0:0:0:0
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0
MAJOR=251
MINOR=0
SEQNUM=1095
SUBSYSTEM=bsg

KERNEL[50982.359131] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/scsi_generic/sg0 (scsi_generic)
ACTION=remove
DEVNAME=/dev/sg0
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/scsi_generic/sg0
MAJOR=21
MINOR=0
SEQNUM=1096
SUBSYSTEM=scsi_generic

KERNEL[50982.359731] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device)
ACTION=remove
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0
SEQNUM=1097
SUBSYSTEM=scsi_device

KERNEL[50982.361349] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk)
ACTION=remove
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0
SEQNUM=1098
SUBSYSTEM=scsi_disk

KERNEL[50982.367606] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
ACTION=remove
DEVNAME=/dev/sda1
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1
DEVTYPE=partition
MAJOR=8
MINOR=1
PARTN=1
SEQNUM=1099
SUBSYSTEM=block

KERNEL[50982.369279] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/block/sda (block)
ACTION=remove
DEVNAME=/dev/sda
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/block/sda
DEVTYPE=disk
MAJOR=8
MINOR=0
SEQNUM=1100
SUBSYSTEM=block

KERNEL[50982.370139] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0 (scsi)
ACTION=remove
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0
DEVTYPE=scsi_device
MODALIAS=scsi:t-0x00
SEQNUM=1101
SUBSYSTEM=scsi

KERNEL[50982.410910] remove   /devices/virtual/bdi/8:0 (bdi)
ACTION=remove
DEVPATH=/devices/virtual/bdi/8:0
SEQNUM=1102
SUBSYSTEM=bdi

KERNEL[50982.411476] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0 (scsi)
ACTION=remove
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0
DEVTYPE=scsi_target
SEQNUM=1103
SUBSYSTEM=scsi

KERNEL[50982.412387] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/scsi_host/host0 (scsi_host)
ACTION=remove
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/scsi_host/host0
SEQNUM=1104
SUBSYSTEM=scsi_host

KERNEL[50982.414188] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0 (scsi)
ACTION=remove
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0
DEVTYPE=scsi_host
SEQNUM=1105
SUBSYSTEM=scsi

KERNEL[50982.415487] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0 (usb)
ACTION=remove
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0
DEVTYPE=usb_interface
INTERFACE=8/6/80
MODALIAS=usb:v1058p10A2d1033dc00dsc00dp00ic08isc06ip50in00
PRODUCT=1058/10a2/1033
SEQNUM=1106
SUBSYSTEM=usb
TYPE=0/0/0

KERNEL[50982.419788] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2 (usb)
ACTION=remove
BUSNUM=001
DEVNAME=/dev/bus/usb/001/007
DEVNUM=007
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2
DEVTYPE=usb_device
MAJOR=189
MINOR=6
PRODUCT=1058/10a2/1033
SEQNUM=1107
SUBSYSTEM=usb
TYPE=0/0/0

UDEV  [50982.973557] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg)
ACTION=remove
DEVNAME=/dev/bsg/0:0:0:0
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0
MAJOR=251
MINOR=0
SEQNUM=1095
SUBSYSTEM=bsg
USEC_INITIALIZED=982359004

UDEV  [50982.999940] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device)
ACTION=remove
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0
SEQNUM=1097
SUBSYSTEM=scsi_device
USEC_INITIALIZED=982362751

UDEV  [50983.095057] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
ACTION=remove
DEVLINKS=/dev/disk/by-id/usb-WD_Elements_10A2_575831314541323038393032-0:0-part1 /dev/disk/by-label/Steven /dev/disk/by-path/platform-3f980000.usb-usb-0:1.2:1.0-scsi-0:0:0:0-part1 /dev/disk/by-uuid/21741F4F6C4915E1
DEVNAME=/dev/sda1
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1
DEVTYPE=partition
ID_BUS=usb
ID_FS_LABEL=Steven
ID_FS_LABEL_ENC=Steven
ID_FS_TYPE=ntfs
ID_FS_USAGE=filesystem
ID_FS_UUID=21741F4F6C4915E1
ID_FS_UUID_ENC=21741F4F6C4915E1
ID_INSTANCE=0:0
ID_MODEL=Elements_10A2
ID_MODEL_ENC=Elements\x2010A2\x20\x20\x20
ID_MODEL_ID=10a2
ID_PART_ENTRY_DISK=8:0
ID_PART_ENTRY_NUMBER=1
ID_PART_ENTRY_OFFSET=2048
ID_PART_ENTRY_SCHEME=dos
ID_PART_ENTRY_SIZE=1953456128
ID_PART_ENTRY_TYPE=0x7
ID_PART_ENTRY_UUID=00023f15-01
ID_PART_TABLE_TYPE=dos
ID_PART_TABLE_UUID=00023f15
ID_PATH=platform-3f980000.usb-usb-0:1.2:1.0-scsi-0:0:0:0
ID_PATH_TAG=platform-3f980000_usb-usb-0_1_2_1_0-scsi-0_0_0_0
ID_REVISION=1033
ID_SERIAL=WD_Elements_10A2_575831314541323038393032-0:0
ID_SERIAL_SHORT=575831314541323038393032
ID_TYPE=disk
ID_USB_DRIVER=usb-storage
ID_USB_INTERFACES=:080650:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=WD
ID_VENDOR_ENC=WD\x20\x20\x20\x20\x20\x20
ID_VENDOR_ID=1058
MAJOR=8
MINOR=1
PARTN=1
SEQNUM=1099
SUBSYSTEM=block
TAGS=:systemd:
USEC_INITIALIZED=8036767

UDEV  [50983.126799] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk)
ACTION=remove
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0
SEQNUM=1098
SUBSYSTEM=scsi_disk
USEC_INITIALIZED=982364537

UDEV  [50983.136895] remove   /devices/virtual/bdi/8:0 (bdi)
ACTION=remove
DEVPATH=/devices/virtual/bdi/8:0
SEQNUM=1102
SUBSYSTEM=bdi
USEC_INITIALIZED=982411342

UDEV  [50983.138940] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/scsi_generic/sg0 (scsi_generic)
ACTION=remove
DEVNAME=/dev/sg0
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/scsi_generic/sg0
MAJOR=21
MINOR=0
SEQNUM=1096
SUBSYSTEM=scsi_generic
USEC_INITIALIZED=982360886

KERNEL[50983.194516] remove   /devices/virtual/bdi/8:1-fuseblk (bdi)
ACTION=remove
DEVPATH=/devices/virtual/bdi/8:1-fuseblk
SEQNUM=1108
SUBSYSTEM=bdi

UDEV  [50983.204265] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/scsi_host/host0 (scsi_host)
ACTION=remove
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/scsi_host/host0
SEQNUM=1104
SUBSYSTEM=scsi_host
USEC_INITIALIZED=982413320

UDEV  [50983.643690] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/block/sda (block)
ACTION=remove
DEVLINKS=/dev/disk/by-id/usb-WD_Elements_10A2_575831314541323038393032-0:0 /dev/disk/by-path/platform-3f980000.usb-usb-0:1.2:1.0-scsi-0:0:0:0
DEVNAME=/dev/sda
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/block/sda
DEVTYPE=disk
ID_BUS=usb
ID_INSTANCE=0:0
ID_MODEL=Elements_10A2
ID_MODEL_ENC=Elements\x2010A2\x20\x20\x20
ID_MODEL_ID=10a2
ID_PART_TABLE_TYPE=dos
ID_PART_TABLE_UUID=00023f15
ID_PATH=platform-3f980000.usb-usb-0:1.2:1.0-scsi-0:0:0:0
ID_PATH_TAG=platform-3f980000_usb-usb-0_1_2_1_0-scsi-0_0_0_0
ID_REVISION=1033
ID_SERIAL=WD_Elements_10A2_575831314541323038393032-0:0
ID_SERIAL_SHORT=575831314541323038393032
ID_TYPE=disk
ID_USB_DRIVER=usb-storage
ID_USB_INTERFACES=:080650:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=WD
ID_VENDOR_ENC=WD\x20\x20\x20\x20\x20\x20
ID_VENDOR_ID=1058
MAJOR=8
MINOR=0
SEQNUM=1100
SUBSYSTEM=block
TAGS=:systemd:
USEC_INITIALIZED=748036370

UDEV  [50983.733473] remove   /devices/virtual/bdi/8:1-fuseblk (bdi)
ACTION=remove
DEVPATH=/devices/virtual/bdi/8:1-fuseblk
SEQNUM=1108
SUBSYSTEM=bdi
USEC_INITIALIZED=3192262

UDEV  [50984.141379] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0 (scsi)
ACTION=remove
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0
DEVTYPE=scsi_device
MODALIAS=scsi:t-0x00
SEQNUM=1101
SUBSYSTEM=scsi
USEC_INITIALIZED=2371212

UDEV  [50984.629455] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0 (scsi)
ACTION=remove
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0
DEVTYPE=scsi_target
SEQNUM=1103
SUBSYSTEM=scsi
USEC_INITIALIZED=2413053

UDEV  [50985.087418] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0 (scsi)
ACTION=remove
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/host0
DEVTYPE=scsi_host
SEQNUM=1105
SUBSYSTEM=scsi
USEC_INITIALIZED=2415484

UDEV  [50985.618300] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0 (usb)
ACTION=remove
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0
DEVTYPE=usb_interface
ID_MODEL_FROM_DATABASE=Elements SE Portable (WDBPCK)
ID_VENDOR_FROM_DATABASE=Western Digital Technologies, Inc.
INTERFACE=8/6/80
MODALIAS=usb:v1058p10A2d1033dc00dsc00dp00ic08isc06ip50in00
PRODUCT=1058/10a2/1033
SEQNUM=1106
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=5647475

UDEV  [50986.078354] remove   /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2 (usb)
ACTION=remove
BUSNUM=001
DEVNAME=/dev/bus/usb/001/007
DEVNUM=007
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2
DEVTYPE=usb_device
ID_BUS=usb
ID_MODEL=Elements_10A2
ID_MODEL_ENC=Elements\x2010A2
ID_MODEL_FROM_DATABASE=Elements SE Portable (WDBPCK)
ID_MODEL_ID=10a2
ID_REVISION=1033
ID_SERIAL=Western_Digital_Elements_10A2_575831314541323038393032
ID_SERIAL_SHORT=575831314541323038393032
ID_USB_INTERFACES=:080650:
ID_VENDOR=Western_Digital
ID_VENDOR_ENC=Western\x20Digital
ID_VENDOR_FROM_DATABASE=Western Digital Technologies, Inc.
ID_VENDOR_ID=1058
MAJOR=189
MINOR=6
PRODUCT=1058/10a2/1033
SEQNUM=1107
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=745644833

답변1

감사해요12월해결책을 찾으려면:

실제로 규칙은 한 줄에 있어야 합니다. 이로 인해 중복 스크립트 호출이 수정되었습니다(고유 변수를 사용하는 경우). 이제 장치 연결이 끊어진 경우에만 스크립트가 호출됩니다. 나에게는 다음 구성이 트릭을 수행했습니다.

ACTION=="remove", ENV{ID_FS_UUID}=="21741F4F6C4915E1", RUN+="/home/pi/HDD_removed.sh"

답변2

다른 사람들이 이미 지적했듯이 코드 조각의 각 줄은 아무 작업도 수행하지 않거나( or 만 있는 줄 ==) 모든 udev 이벤트에 대해 명령을 실행하는( =or 만 있는 줄 +=) 별도의 규칙입니다. 전체 규칙을 하나의 논리적 라인에 배치해야 합니다.

udev 규칙에서 줄을 분할할 수 있지만 규칙이 다음 줄에서 계속되는 경우 줄 끝에 백슬래시를 추가해야 합니다. 즉, 논리 행에는 백슬래시-개행 문자 두 문자 시퀀스가 ​​포함될 수 있으며 이 시퀀스는 무시됩니다.

ACTION=="remove", \
ENV{ID_MODEL}=="Elements_10A2", \
RUN+="/home/pi/HDD_removed.sh"

관련 정보