Primeiro, coloque o script de shell scheduler4usb
em $PATH
(por exemplo, /usr/bin
):
#!/bin/bash
# Usage: ./script device scheduler
# If your are using util-linux 2.22, you must change this line to:
# fdisk /dev/$1 -l 2>&1 >/dev/null | grep -q "doesn't contain a valid partition table"
#
fdisk /dev/$1 -l 2>&1 >/dev/null | grep -q "This doesn't look like a partition table"
# If this device has a partition table.
if (($?==0)); then
echo $2 > /sys/block/$1/queue/scheduler
fi
exit
Não se esqueça de chmod +x scheduler4usb
do seu script!
Em seguida, escreva a regra em /etc/udev/rules.d/91-change-schduler.rules
:
SUBSYSTEMS=="usb", ACTION=="add", KERNEL=="sd?", RUN+="/usr/local/bin/scheduler4usb %k deadline"