User talk:Jmdana

From ArchWiki
Latest comment: 16 February 2015 by Lahwaacz in topic udev: treat a device as removable

udev: treat a device as removable

Re [1], why have you replaced a section which was clearly talking about USB drives, with a content specific to eSATA drives? Also, when the matching is "fixed", why have you used UDISKS_AUTO instead of UDISKS_SYSTEM_INTERNAL? -- Lahwaacz (talk) 17:48, 15 February 2015 (UTC)Reply[reply]


As I said in the summary of the change, my motivation was that the proposed command didn't work.
The section title is "Some devices, that should be treated as removable, are not". It was just using USB as an example, the same way that I use eSATA. Also, my example can be used for any kind of device, USB or not, as long as it has a DEVPATH (i.e. always, not like the serial). Maybe I should clarify that it's not eSATA specific...
UDISKS_SYSTEM_INTERNAL doesn't imply auto mounting, which is what most people would expect from removable devices. UDISKS_AUTO does: [2]. Moreover UDISKS_SYSTEM_INTERNAL is about requiring special permissions to access [3] not about being removable or not.
Please let me know if I should clarify something specifically.
EDIT: I have removed the mention to eSATA drives so it's subsystem agnostic now.
Jmdana (talk) 18:31, 15 February 2015 (UTC)Reply[reply]

It still is not subsystem agnostic - DEVPATH is bound to the controller and port, not to the device, so when you connect a drive to a different port, the DEVPATH will be different. It is not a problem as long as the computer has only a single eSATA port, but there are usually multiple USB ports on a computer. In contrast, serial is bound only to the specific drive, so it does not suffer this problem.
It also appears that UDISKS_AUTO is a variable specific to udisks2, whereas UDISKS_SYSTEM_INTERNAL is specific to udisks 1.0.5. But its "newer" counterpart is UDISKS_SYSTEM, which when set to 0 (as in the original section) should not require any special permissions (I don't use either version of udisks so I don't really know...).
-- Lahwaacz (talk) 18:39, 15 February 2015 (UTC)Reply[reply]

True, I'll look for some other identifier instead of DEVPATH.
UDISKS_SYSTEM allows you to mount without root password ([4]), but not auto-mounting. It looks like UDISKS_SYSTEM_INTERNAL in udisks1 was a mix of UDISKS_SYSTEM and UDISKS_AUTO in udisks2. I will clarify that the instructions are for udisks2 only, I don't have udisks1 so I can't test if my guess is true.
Jmdana (talk) 18:52, 15 February 2015 (UTC)Reply[reply]

What do you think about this? I'm keeping the old version as well so people using udisks set the right parameter (UDISKS_SYSTEM_INTERNAL). UDISKS_AUTO should be enough but for devices declared as internal by default I'm adding UDISKS_SYSTEM, which is what you would expect from a removable device.


Some devices, that should be treated as removable, are not

You need to create a custom udev rule for that particular device. To get definitive information of the device you can use its ID_SERIAL (remember to change /dev/sdb if needed):

$ udevadm info /dev/sdb | grep ID_SERIAL

udisks

Then we create a rule in /etc/udev/rules.d/ and set UDISKS_SYSTEM_INTERNAL variable to 0.

/etc/udev/rules.d/50-external-myhomedisk.rules
ENV{ID_SERIAL}=="serial_number", ENV{UDISKS_SYSTEM_INTERNAL}="0"

Remember to reload udev rules with udevadm control --reload. Next time you plug your device in, it will be treated as an external drive.

udisks2

Then we create a rule in /etc/udev/rules.d/ and set both UDISKS_AUTO="1" and UDISKS_SYSTEM="0"

/etc/udev/rules.d/99-removable.rules
ENV{ID_SERIAL}=="serial_number", ENV{UDISKS_AUTO}="1", ENV{UDISKS_SYSTEM}="0"

Remember to reload udev rules with udevadm control --reload. Next time you plug your device in, it will be treated as an external drive.


Jmdana (talk) 20:32, 15 February 2015 (UTC)Reply[reply]
Nice idea, but I think that ID_SERIAL_SHORT should be used instead (it is only the serial, does not include vendor and product name). As ID_SERIAL* variables are exposed for my SATA /dev/sda, I assume they are also for eSATA drives? Anyway, feel free to merge the section into the main page. -- Lahwaacz (talk) 21:12, 15 February 2015 (UTC)Reply[reply]
Yes, I thought the same, but then after some googling I realized that there are devices without ID_SERIAL_SHORT out there (!). I'll suggest any of the two. I found ID_SERIAL in all my block devices (SATA, eSATA and USB).
Jmdana (talk) 21:34, 15 February 2015 (UTC)Reply[reply]
Very well done, thank you for doing the research and updating the page. I've only added the links to the manual pages, so that the section not only says what to do, but also why. Closing. -- Lahwaacz (talk) 08:33, 16 February 2015 (UTC)Reply[reply]