LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-06-2022, 09:39 AM   #1
SpacePlod
Member
 
Registered: Jan 2014
Distribution: Slackware
Posts: 115

Rep: Reputation: Disabled
UDEV rule for usb-storage (add to group 'plugdev')?


I'm trying to write a udev rule that will allow access to USB storage devices for members of 'plugdev'. The goal is to allow using 'device_add' in qemu. I've done it successfully before and kept notes, but for some reason it's not working right now (This is on 15.0).

Code:
$ cat /etc/udev/rules.d/50-usb.rules
ACTION=="add", SUBSYSTEM=="usb", DRIVERS=="usb-storage", MODE="0660", GROUP="plugdev"
I've tried various combinations of the above and swapped out other descriptors as well:
Code:
KERNEL=="sd?"
SUBSYSTEMS=="usb"
SUBSYSTEM=="block"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
etc.
I'm getting the descriptors from the output of udevadm:

Code:
# udevadm info /dev/sdb -a | head -n 50

...

  looking at device '/devices/pci0000:00/0000:00:08.1/0000:0d:00.3/usb6/6-4/6-4.4/6-4.4.4/6-4.4.4:1.0/host6/target6:0:0/6:0:0:0/block/sdb':
    KERNEL=="sdb"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{ext_range}=="256"
    ATTR{range}=="16"
    ATTR{alignment_offset}=="0"
    ATTR{diskseq}=="39"
    ATTR{ro}=="0"
    ATTR{stat}=="      66        0     3280      239        0        0        0        0        0      235      239        0        0        0        0        0        0"
    ATTR{events_poll_msecs}=="-1"
    ATTR{events_async}==""
    ATTR{size}=="60566016"
    ATTR{discard_alignment}=="0"
    ATTR{capability}=="1"
    ATTR{hidden}=="0"
    ATTR{removable}=="1"
    ATTR{events}=="media_change"
    ATTR{inflight}=="       0        0"

  looking at parent device '/devices/pci0000:00/0000:00:08.1/0000:0d:00.3/usb6/6-4/6-4.4/6-4.4.4/6-4.4.4:1.0/host6/target6:0:0/6:0:0:0':
    KERNELS=="6:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{evt_media_change}=="0"
    ATTRS{evt_mode_parameter_change_reported}=="0"
    ATTRS{evt_inquiry_change_reported}=="0"
    ATTRS{vendor}=="Corsair "
    ATTRS{evt_capacity_change_reported}=="0"
...
I've tried re-numbering the rule (10-usb.rules and 99-usb.rules) without luck, just in case the rule is being overridden. The QEMU documentation simply mentions using "chown" directly on the /dev/bus/ device. If anyone has any pointers (or perhaps a better approach), it would be much appreciated.
 
Old 09-11-2022, 12:41 PM   #2
henca
Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 956

Rep: Reputation: 648Reputation: 648Reputation: 648Reputation: 648Reputation: 648Reputation: 648
Quote:
Originally Posted by SpacePlod View Post
I'm trying to write a udev rule that will allow access to USB storage devices for members of 'plugdev'.
This is my udev rule on a Slackware 14.2 machine to let normal users access a USB device:

/etc/udev/rules.d/92-garmin.rules
Code:
# Garmin DriveAssist 50 LMT-D
ATTRS{idVendor}=="091e", ATTRS{idProduct}=="28de", MODE="666"
I did not use a group, but that would probably also be possible with something like:

Code:
GROUP="plugdev", MODE="066"
instead of
Code:
MODE="666"
Quote:
Originally Posted by SpacePlod View Post
The goal is to allow using 'device_add' in qemu. I've done it successfully before and kept notes, but for some reason it's not working right now (This is on 15.0).
Once you get the permissions right the next step might be tricky. To give qemu access to a USB device requires that no kernel driver on the host machine is used to access the device. You can give qemu access to the device with device_add in the monitor, or from the command line, like in my example:

Code:
-usb -device usb-ehci,id=ehci -device usb-host,bus=ehci.0,vendorid=0x091e,productid=0x28de
However, in your case a kernel driver is most likely loaded on the host machine for the USB storage device. Then it will not be a good idea to give the device also to qemu. You will end up with two different kernels messing with the same hardware. Instead, it will probably be better to mount the USB storage device on the host machine and then share it to the guest with something like smb.

regards Henrik
 
  


Reply



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
plugdev group mounting usb pen disks and sd cards problems Laodiceans Slackware 6 07-15-2012 02:19 PM
VFAT Partition Not Working Properly (shows as plugdev) the_new_z Linux - Newbie 8 06-08-2008 12:15 PM
plugdev & xfce without desktop icons cmk77 Slackware 4 07-23-2007 12:12 PM
group: add complete group into other group max_mad SUSE / openSUSE 1 04-12-2006 01:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:32 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