# [resolved] Udev rule is not working!

## biergaizi

I write a udev rule, but it's not working!

More information are avaliable here:

```

localhost biergaizi # cat /etc/udev/rules.d/91-change-schduler.rules 

#SUBSYSTEMS=="usb", KERNEL=="sd??", ACTION=="add", RUN+="echo deadline > /sys/block/%k/queue/scheduler"

ACTION=="add", KERNEL=="sd??", RUN+="/usr/local/bin/USB"

localhost biergaizi # cat /usr/local/bin/USB

#!/bin/bash

echo 'Hello World!' >>"/home/biergaizi/udev.out"

exit

localhost biergaizi # ls -l /usr/local/bin/USB

-rwxr-xr-x 1 root root 66 10月  1 11:55 /usr/local/bin/USB

```

Why?

----------

## PaulBredbury

 *biergaizi wrote:*   

> ACTION=="add", KERNEL=="sd??"

 

Maybe that runs *before* the partition is mounted read/write?

For kicks, try adding e.g. "sleep 10" to the start of your BASH script.

----------

## biergaizi

 *PaulBredbury wrote:*   

>  *biergaizi wrote:*   ACTION=="add", KERNEL=="sd??" 
> 
> Maybe that runs *before* the partition is mounted read/write?
> 
> For kicks, try adding e.g. "sleep 10" to the start of your BASH script.

 

Please read my script carefully.

This script & udev rule is trying to write a file to my home folder (on my local hard drive), when a USB device is plugin.

Nothing to do with ro/rw.

----------

## biergaizi

This is my own mistake.

KERNEL=="sd??" matches to the device with a partition table (/dev/sda1) only. If your device doesn't have a partition table (/dev/sda), the rule isn't working.

You can change your rule to KERNEL=="sd?" to detect all kind of device.

----------

