You are not logged in.

#1 2014-08-18 12:53:56

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,464

[SOLVED] Need to write an udev rule for usb memory sticks.

Hi all,
For some time i've used an udev rule to boost the transfer speed of a particular usb stick:

SUBSYSTEM=="block", ATTRS{model}=="Cruzer Contour  ", RUN+="/bin/sh -c '/bin/echo 1024 > /sys/block/%k/device/max_sectors'"

Write speeds went from about 25MBps to a nice 29MBps.

So i tried another very cheap stick and it went from 13 to 25 (!)

...so i tried another, even cheaper stick and it went from 4.9 to 5.1 by setting max_sectors to 480 (defaults was 240).

In the end, i'd like to set all of the usb stick i plug to transfer 480 sectors at once instead of the default 240.
how could this be done via udev without affecting other usb devices?

Thanks.

Edit-
i tried this:

SUBSYSTEM=="block", ATTRS{max_sectors}=="240", ATTRS{removable}=="1", RUN+="/bin/sh -c '/bin/echo 480 > /sys/block/%k/device/max_sectors'"

but it doesn't work

While this one does:

SUBSYSTEM=="block", ATTRS{max_sectors}=="240", RUN+="/bin/sh -c '/bin/echo 480 > /sys/block/%k/device/max_sectors'"

...seems that i am missing something; how can i specify multiple attrs?

Last edited by kokoko3k (2014-08-18 19:41:12)


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#2 2014-08-18 15:13:49

ukhippo
Member
From: Non-paged pool
Registered: 2014-02-21
Posts: 366

Re: [SOLVED] Need to write an udev rule for usb memory sticks.

All the ATTRS must be from the same parent. Note your rule also matches partitions.
I suggest you use something like

KERNEL=="sd?", ATTR{removable}=="1", ATTRS{max_sectors}=="240", RUN+="..."

Offline

#3 2014-08-18 17:12:15

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Need to write an udev rule for usb memory sticks.

Moving to Kernel and Hardware...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#4 2014-08-18 19:40:53

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,464

Re: [SOLVED] Need to write an udev rule for usb memory sticks.

ukhippo wrote:

All the ATTRS must be from the same parent. Note your rule also matches partitions.
I suggest you use something like

KERNEL=="sd?", ATTR{removable}=="1", ATTRS{max_sectors}=="240", RUN+="..."

Thanks, marking as solved smile


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#5 2014-08-28 08:21:31

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,464

Re: [SOLVED] Need to write an udev rule for usb memory sticks.

Okay, why an external usb hdd isn't seen as removable by udev?
going to drop the removable ATTR from the rule, or somebody has a better idea?


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

Board footer

Powered by FluxBB