[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: udev applied to SDHC card. Two systems compared.



On 27.12.2021 10:32, peter@easthope.ca wrote:
Any ideas about why udev assigns a symlink on the desktop system and
not on the Sharp Mebius laptop?
I think it is impossible to answer that question without actually looking at these systems. Perhaps it is a problem of poorly written rule that doesn't take into account difference between host devices,
or a race condition of some sort between the rules.
It is always better to make udev rules to identify target devices properly.

Here is a little howto, where I will use my USB drive as an example:
1. Let's make a '.rules' file and make sure it will be processed last:
    $ sudo touch /etc/udev/rules.d/99-myusbdrive.rules

2. Now we have to see what properties and environment variables udev made available for us, and choose among them the ones that will always identify our currently plugged in device (I've skipped some output):
    $ udevadm info /dev/sdc1
    ...
    E: ID_VENDOR=Kingston
    ...
    E: ID_MODEL=DT101_II
    ...
    E: ID_SERIAL_SHORT=001CC0EC0000F031C7E50990
    ...
    E: ID_FS_LABEL=KINGSTON
    ...
    E: ID_FS_UUID=000C-123F
    ...

3. Using this information we can now add to file "99-myusbdrive.rules" something like this:
# Rule for Kingston DT101_II to assign symlink and ACL.
#
ENV{ID_VENDOR}=="Kingston", ENV{ID_MODEL}=="DT101_II", \
ENV{ID_SERIAL_SHORT}=="001CC0EC0000F031C7E50990", \
ENV{ID_FS_UUID}=="000C-123F", \
SYMLINK+="personalusb", OWNER="alex", GROUP="alex"

4. Now let's reconnect the device and check if '.rules' file worked:
    $ ls -la /dev/personalusb
    lrwxrwxrwx 1 root root 4 Dec 27 19:57 /dev/personalusb -> sdc1
    $ ls -la /dev/sdc1
    brw-rw---- 1 alex alex 8, 33 Dec 27 19:57 /dev/sdc1

Feel free to adjust the rule to meet your goals.

--
With kindest regards, Alexander.

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀⠀⠀⠀


Reply to: