LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 06-30-2015, 10:52 AM   #1
IUgDT718Oh
LQ Newbie
 
Registered: Jun 2015
Posts: 5

Rep: Reputation: Disabled
udev rules for providing /dev/raw/raw? fail


OL6 uname -a = Linux bigbox1 3.8.13-68.3.3.el6uek.x86_64 #2 SMP Tue Jun 23 23:43:15 PDT 2015 x86_64 x86_64 x86_64 GNU/Linux

I have four usb disks that I plug in via a hub. They are recognized in dmesg | less -N, just one example for plugging in:

1316 usb 2-1.2.4.4: new high-speed USB device number 25 using ehci-pci
1317 usb 2-1.2.4.4: New USB device found, idVendor=174c, idProduct=55aa
1318 usb 2-1.2.4.4: New USB device strings: Mfr=2, Product=3, SerialNumber=1
1319 usb 2-1.2.4.4: Product: External HDD
1320 usb 2-1.2.4.4: Manufacturer: 01234567890123456789012345678901234567890123
1321 usb 2-1.2.4.4: SerialNumber: 20120223126E
1322 scsi26 : usb-storage 2-1.2.4.4:1.0
1323 scsi 26:0:0:0: Direct-Access TOSHIBA MK3276GSX GS00 PQ: 0 ANSI: 5
1324 sd 26:0:0:0: Attached scsi generic sg2 type 0
1325 sd 26:0:0:0: [sdb] 625142448 512-byte logical blocks: (320 GB/298 GiB)
1326 sd 26:0:0:0: [sdb] Write Protect is off
1327 sd 26:0:0:0: [sdb] Mode Sense: 23 00 00 00
1328 sd 26:0:0:0: [sdb] No Caching mode page found
1329 sd 26:0:0:0: [sdb] Assuming drive cache: write through
1330 sd 26:0:0:0: [sdb] No Caching mode page found
1331 sd 26:0:0:0: [sdb] Assuming drive cache: write through
1332 sdb: sdb1
1333 sd 26:0:0:0: [sdb] No Caching mode page found
1334 sd 26:0:0:0: [sdb] Assuming drive cache: write through
1335 sd 26:0:0:0: [sdb] Attached SCSI disk

In particular, I try to create a rule in /etc/udev/rules.d/60-raw.rules that triggers on

SerialNumber: 20120223126E

udev sees the device:

[root@bigbox1 ~]# udevadm info --query=all -n /dev/sdb
P: /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2.4/2-1.2.4.4/2-1.2.4.4:1.0/host26/target26:0:0/26:0:0:0/block/sdb
N: sdb
W: 642
S: block/8:16
S: disk/by-id/usb-TOSHIBA_MK3276GSX_20120223126E-0:0
S: disk/by-path/pci-0000:00:1d.0-usb-0:1.2.4.4:1.0-scsi-0:0:0:0
E: UDEV_LOG=3
E: DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2.4/2-1.2.4.4/2-1.2.4.4:1.0/host26/target26:0:0/26:0:0:0/block/sdb
E: MAJOR=8
E: MINOR=16
E: DEVNAME=/dev/sdb
E: DEVTYPE=disk
E: SUBSYSTEM=block
E: ID_VENDOR=TOSHIBA
E: ID_VENDOR_ENC=TOSHIBA\x20
E: ID_VENDOR_ID=174c
E: ID_MODEL=MK3276GSX
E: ID_MODEL_ENC=MK3276GSX\x20\x20\x20\x20\x20\x20\x20
E: ID_MODEL_ID=55aa
E: ID_REVISION=GS00
E: ID_SERIAL=TOSHIBA_MK3276GSX_20120223126E-0:0
E: ID_SERIAL_SHORT=20120223126E
E: ID_TYPE=disk
E: ID_INSTANCE=0:0
E: ID_BUS=usb
E: ID_USB_INTERFACES=:080650:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=usb-storage
E: ID_PATH=pci-0000:00:1d.0-usb-0:1.2.4.4:1.0-scsi-0:0:0:0
E: ID_PART_TABLE_TYPE=dos
E: LVM_SBIN_PATH=/sbin
E: DEVLINKS=/dev/block/8:16 /dev/disk/by-id/usb-TOSHIBA_MK3276GSX_20120223126E-0:0 /dev/disk/by-path/pci-0000:00:1d.0-usb-0:1.2.4.4:1.0-scsi-0:0:0:0

All my attempts to write one "add" and one "remove" rule for achieving

/bin/raw /dev/raw/raw1 %N

when adding and

/bin/raw /dev/raw/raw1 0 0

when removing failed. I am pretty confident that I am doing something wrong. Maybe someone can show me the right rule?

Note: I have several usb disks, and several places where those can appear. Is there a more suitable tag than ID_SERIAL_SHORT or SerialNumber?

My attempts so far:

ACTION=="add",SUBSYSTEM=="usb",ENV{SerialNumber}=="20120223126E",RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="remove",SUBSYSTEM=="usb",ENV{SerialNumber}=="20120223126E",RUN+="/bin/raw /dev/raw/raw1 0 0"

ACTION=="add",SUBSYSTEM=="usb",ATTR{SerialNumber}=="20120223126E",RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="remove",SUBSYSTEM=="usb",ATTR{SerialNumber}=="20120223126E",RUN+="/bin/raw /dev/raw/raw1 0 0"

ACTION=="add",SUBSYSTEM=="usb",ENV{ID_SERIAL_SHORT}=="20120223126E",RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="remove",SUBSYSTEM=="usb",ENV{ID_SERIAL_SHORT}=="20120223126E",RUN+="/bin/raw /dev/raw/raw1 0 0"

ACTION=="add",SUBSYSTEM=="usb",ATTR{ID_SERIAL_SHORT}=="20120223126E",RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="remove",SUBSYSTEM=="usb",ATTR{ID_SERIAL_SHORT}=="20120223126E",RUN+="/bin/raw /dev/raw/raw1 0 0"

Between each of these attempts, I made sure I did

udevadm control --reload-rules
udevadm trigger
# unplug the disk
# plug in the disk

Note: of course the /bin/raw command line itself works. I even prepared an executable script /tmp/raw that just takes all argument, echoes them to /tmp/raw.out and passes them to /bin/raw. So I know for sure the RUN+= was *not* executed.
 
  


Reply

Tags
raw, rules, udev



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
relation between udev and raw devices amar.sree Linux - Newbie 1 02-17-2012 02:02 AM
LXer: RAW Magic In Digikam: Understanding RAW Photo Settings LXer Syndicated Linux News 0 04-26-2011 04:40 PM
Creating a Raw Device via Udev Rules trectenw Red Hat 1 04-14-2010 08:24 AM
udev, create raw disk device, how? thllgo Red Hat 2 01-23-2008 10:50 AM
UDEV and Raw devices swissworks Slackware 6 09-14-2004 01:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 06:01 AM.

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