You are not logged in.
Pages: 1
How do I assign a custom group to newly created usb storage devices in /dev directory? I noticed they are added to "disk" group by default, but I'd like to have them in a different group than non-removable hard disks.
Offline
Linux ArchLinux 3.2.8-1-ARCH
#1 SMP PREEMPT Mon Feb 27 21:51:46 CET 2012 x86_64 AMD FX(tm)-8120 Eight-Core Processor AuthenticAMD GNU/Linux
8192MB DDR3 1300MHz | Asus m5a97 | GeForce GTX 550 Ti | 120 GB SSD
Offline
Ok, so I created the file /etc/udev/rules.d/00.rules with the following contents:
SUBSYSTEM=="usb", KERNEL=="sd*", NAME="%k", GROUP="removable"
Then I told udev to reload it's rules with "udevadm control --reload-rules" and plugged in the pendrive. The files /dev/sdb* were not assigned to the 'removable' group, though.
Offline
Did you create the group removable?
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
Did you create the group removable?
Yes
Offline
Ok, I managed to do it the following way. First of all I created file /etc/udev/rules.d/xx.rules (it looks like the rules are loaded and applied in alphabetical order, so I added this as the last one to override system defaults). The file contents is as follows:
ENV{ID_USB_DRIVER}="usb-storage", KERNEL=="sd*", GROUP="removable"
I used ENV{ID_USB_DRIVER} instead of SUBSYSTEM=="usb", because the latter didn't work. Now some testing with:
$ sudo udevadm test $(udevadm info --query=path --name=/dev/sdb)
...
udev_rules_apply_to_event: GROUP 6 /lib/udev/rules.d/50-udev-default.rules:67
....
udev_rules_apply_to_event: GROUP 1000 /etc/udev/rules.d/xx.rules:1
6 is the id of arch's default disk group, 1000 of my new removable group. Voila...
All of the above was infered rather from experimenting than RTFMing so I you can do it better, please leave a comment.
Offline
Pages: 1