Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 10-21-2006, 11:18 AM   #1
Senior Member
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
udev does not run program on remove

I am playing around with udev and automounting.
I put the following rule in /etc/udev/rules:
BUS=="scsi",DRIVER=="sd",SYSFS{model}=="USB Disk        ",SYSFS{vendor}=="Generic ",SYMLINK+="_usbdisk%n",RUN+="/etc/udev/scripts/automount"
which creates the symlink as expected. The "automount" script is as follows:
printenv >> /tmp/udev.log
echo >> /tmp/udev.log
which executes as expected for adds, but never for removes, although udevmonitor shows that removes are intercepted:
UDEV [1161443405.906373] add@/block/sdb/sdb1
and later
UDEV [1161443416.496382] remove@/block/sdb/sdb1
So what do I have to do in order to have my script run at removal as well?
Old 10-22-2006, 05:01 AM   #2
Senior Member
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
I think you need an ACTION="remove" that matches your other rule. I've not done this but I think thats how it's done.

ACTION="remove", SYSFS{model}=="USB Disk ", SYSFS{vendor}=="Generic ", RUN+="/etc/udev/scripts/automount"
Old 10-22-2006, 05:24 AM   #3
Senior Member
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Original Poster
Rep: Reputation: 46
I've changed the rules to this:
ACTION=="add",BUS=="scsi",DRIVER=="sd",SYSFS{model}=="USB Disk ",SYSFS{vendor}=="Generic ",SYMLINK+="_usbdisk%n",RUN+="/etc/udev/scripts/automount add"
ACTION=="remove",BUS=="scsi",DRIVER=="sd",SYSFS{model}=="USB Disk ",SYSFS{vendor}=="Generic ",RUN+="/etc/udev/scripts/automount remove"
and the script to
echo "parameter = $1" >> /tmp/udev.log
printenv >> /tmp/udev.log
echo >> /tmp/udev.log
The events get caught properly:
root@slackw:~$ udevmonitor
udevmonitor prints the received event from the kernel [UEVENT]
and the event which udev sends out after rule processing [UDEV]

UEVENT[1161508773.336420] add@/devices/pci0000:00/0000:00:03.3/usb1/1-4
UEVENT[1161508773.336474] add@/devices/pci0000:00/0000:00:03.3/usb1/1-4/1-4:1.0
UEVENT[1161508773.336484] add@/class/scsi_host/host4
UEVENT[1161508773.336493] add@/class/usb_device/usbdev1.6
UDEV [1161508773.337278] add@/devices/pci0000:00/0000:00:03.3/usb1/1-4
UDEV [1161508773.378090] add@/devices/pci0000:00/0000:00:03.3/usb1/1-4/1-4:1.0
UDEV [1161508773.379450] add@/class/scsi_host/host4
UDEV [1161508773.386399] add@/class/usb_device/usbdev1.6
UEVENT[1161508778.336995] add@/devices/pci0000:00/0000:00:03.3/usb1/1-4/1-4:1.0/host4/target4:0:0/4:0:0:0
UEVENT[1161508778.337283] add@/class/scsi_disk/4:0:0:0
UEVENT[1161508778.488173] add@/block/sda
UEVENT[1161508778.488200] add@/block/sda/sda1
UEVENT[1161508778.488209] add@/class/scsi_device/4:0:0:0
UEVENT[1161508778.488218] add@/class/scsi_generic/sg0
UDEV [1161508778.506964] add@/devices/pci0000:00/0000:00:03.3/usb1/1-4/1-4:1.0/host4/target4:0:0/4:0:0:0
UDEV [1161508778.507682] add@/class/scsi_disk/4:0:0:0
UDEV [1161508778.532756] add@/block/sda
UDEV [1161508778.568888] add@/class/scsi_device/4:0:0:0
UDEV [1161508778.571559] add@/class/scsi_generic/sg0
UDEV [1161508778.755430] add@/block/sda/sda1
UEVENT[1161508786.825967] remove@/class/scsi_generic/sg0
UEVENT[1161508786.826001] remove@/class/scsi_device/4:0:0:0
UEVENT[1161508786.826011] remove@/class/scsi_disk/4:0:0:0
UEVENT[1161508786.826020] remove@/block/sda/sda1
UEVENT[1161508786.826030] remove@/block/sda
UEVENT[1161508786.826039] remove@/devices/pci0000:00/0000:00:03.3/usb1/1-4/1-4:1.0/host4/target4:0:0/4:0:0:0
UEVENT[1161508786.826049] remove@/class/scsi_host/host4
UEVENT[1161508786.826058] remove@/devices/pci0000:00/0000:00:03.3/usb1/1-4/1-4:1.0
UEVENT[1161508786.826068] remove@/class/usb_device/usbdev1.6
UEVENT[1161508786.826077] remove@/devices/pci0000:00/0000:00:03.3/usb1/1-4
UDEV [1161508786.827266] remove@/class/scsi_generic/sg0
UDEV [1161508786.828172] remove@/class/scsi_device/4:0:0:0
UDEV [1161508786.829055] remove@/class/scsi_disk/4:0:0:0
UDEV [1161508786.830149] remove@/block/sda/sda1
UDEV [1161508786.831270] remove@/devices/pci0000:00/0000:00:03.3/usb1/1-4/1-4:1.0/host4/target4:0:0/4:0:0:0
UDEV [1161508786.832502] remove@/class/scsi_host/host4
UDEV [1161508786.833552] remove@/class/usb_device/usbdev1.6
UDEV [1161508786.834596] remove@/block/sda
UDEV [1161508786.835616] remove@/devices/pci0000:00/0000:00:03.3/usb1/1-4/1-4:1.0
UDEV [1161508786.836746] remove@/devices/pci0000:00/0000:00:03.3/usb1/1-4
root@slackw:/tmp$ grep parameter udev.log
parameter = add
parameter = add
parameter = add

Last edited by uselpa; 10-22-2006 at 05:26 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
slackware-current, udev 0.96, and custom udev rules not working rignes Slackware 6 08-10-2006 04:43 AM
remove a program faris10 General 3 05-11-2006 05:00 AM
how do i remove a specific program? Blu-star Linux - Software 4 01-04-2004 10:00 PM
How do i remove a program? SykoMachine Linux - Software 5 01-04-2004 04:55 PM
Viewing program messages when program isn't run from command line? Locura Linux - Software 1 09-27-2003 09:19 AM > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:05 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration