Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #243478

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

From "Alexander V. Makartsev" <avbetev@gmail.com>
Newsgroups linux.debian.user
Subject Re: udev applied to SDHC card. Two systems compared.
Date 2021-12-27 18:40 +0100
Message-ID <Dz28y-eA-5@gated-at.bofh.it> (permalink)
References <DyR3r-1Xz-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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
⠈⠳⣄⠀⠀⠀⠀

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

udev applied to SDHC card.  Two systems compared. peter@easthope.ca - 2021-12-27 06:50 +0100
  Re: udev applied to SDHC card. Two systems compared. "Alexander V. Makartsev" <avbetev@gmail.com> - 2021-12-27 18:40 +0100
    Re: udev applied to SDHC card. Two systems compared. peter@easthope.ca - 2021-12-28 22:40 +0100
      Re: udev applied to SDHC card. Two systems compared. "Alexander V. Makartsev" <avbetev@gmail.com> - 2021-12-29 00:10 +0100
        Re: udev applied to SDHC card. Two systems compared. peter@easthope.ca - 2021-12-29 20:30 +0100
  Re: udev applied to SDHC card.  Two systems compared. David Wright <deblis@lionunicorn.co.uk> - 2022-01-03 05:30 +0100

csiph-web