3

I have an external hard-disk, connected by usb. Because it is external, the /dev file for it is in group floppy. However I use it as if it is internal. I also sometimes format sd cards and other usb devices, I am in group floppy to do this. I do not want to accidentally format this hard-disk, so do not want it to be in group floppy.

How can I configure it to be in a different group. It is currently managed by udev. I have not been able to figure out how to configure udev.

I am using Debian 7 (Wheezy)

1

A simple UDEV rule like that should help:

SUBSYSTEM=="block", ATTRS{idVendor}=="058f", ATTRS{idProduct}=="6366", GROUP="disk"

Add it to, say, /etc/udev/rules.d/92-treat-my-usb-drive-as-internal.rules, so it would be proccessed after 91-permissions.rules, which assign the floppy group.

idVendor and idProduct of your USB-drive could be detected with $ lsusb:

$ lsusb
Bus 001 Device 005: ID 058f:6366 Alcor Micro Corp. Multi Flash Reader
<...>

Please note, that they are not quite unique: they identify model, not an every single device. If it is a problem to you, you could look in $ udevadm info -a -n /dev/sdx for something more unique.

By the way, in Jessie, 91-permissions.rules is dropped (see bug #751892), so you also have to prepare to do the opposite after upgrading in order to keep formatting SD-cards.

  • That looks like it will do what I want. Can I use disk labels (the things that appear in /dev/disk/by-label). – ctrl-alt-delor Nov 19 '14 at 21:00
  • @richard Try to figure out: SUBSYSTEM=="block", ENV{ID_FS_LABEL_ENC}=="MYSTORAGE", GROUP="disk" :-) – Dmitry Alexandrov Nov 20 '14 at 1:00
  • @richard I think, that it would work correctly, but the correct result is not that you expect: labels are assigned to partitions, so the partition (say, /dev/sdb1) would belong to group disk, while the whole disk (/dev/sdb) – still to group floppy, so that one still might wipe it without superuser rights. – Dmitry Alexandrov Nov 20 '14 at 1:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.