# slow udev rules

## dermartn

hey,

I have a custom udev rule for running a script for a usb-stick.

ACTION=="add", BUS=="usb", KERNEL=="sd?1", SYSFS{idVendor}=="xxxx", SYMLINK="usbstick%n", RUN+="/path/to/my/script"

udev is reacting and is running alright, but it is very slow. the script runs in a few secends, when I run it manually. but with udev it takes more then three minutes from plug in the usb-stick to finish the script! that's slow.

any ideas how to speed up the rule-script combination?

- dermartn

----------

## PaulBredbury

You should first identify whether it's udev, or your script, which is slow.

It's rather difficult for us to debug, without you showing your script  :Wink: 

----------

## dermartn

I will post it when I am back home tonight.

But when I run the script manually, it only needs some seconds and udev needs more than 3 minutes...

----------

## dermartn

late, but here is the script:

```

pmount /dev/usbstick1 /media/disk

sudo cryptsetup luksOpen /dev/sdb1 files --key-file /media/disk/files.key

mount /dev/mapper/files

pumount /dev/usbstick1

```

as written before, when it's ran manually, it is fast, via udev-rules it is slow...

any ideas?

----------

## PaulBredbury

Well, narrow it down to which line is the problem.  Insert in-between the lines, a line such as:

touch /root/step1

... your first line of code

touch /root/step2

... your second line of code

touch ... and so on

That shows you how long each line takes.

----------

