Welcome to the Linux Foundation Forum!

Exercise 27.1 - udev

I'm not having any luck trying to get the "myusb" symlink to show up in /dev.

I have double-checked that the rules file is in the correct location (/etc/udev/rules.d) with the correct name and syntax. I have confirmed that the USB stick is being detected by monitoring dmesg. I have even reloaded udev with udevadm control --reload.

I'm not sure what else to do.

Comments

  • coop
    coop Posts: 916

    I just ran the exercise on a RHEL 8 system and it worked perfectly. Can you please tell us what Distribution you are using (name and version) and whether or not this is a physical machine or a virtual machine under a hypervisor. If it is a VM there are a bunch of reasons the USB stick could not be passed through to the VM that have to do with hypervisor settings.

  • Hi coop, this is a physical machine and the dynamic hardware detection is working OK, the USB stick is being mounted.

    I am using Linux Mint 19.3 and the output of uname -a is:
    Linux ZeroGravitas 5.4.0-42-generic #46~18.04.1-Ubuntu SMP Fri Jul 10 07:21:24 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

  • coop
    coop Posts: 916

    I have no idea and I do not have any ubuntu-based physical machine to test with. I'm sure you have tried a reboot and the --reload command should have accomplished this anyway. It's possible it is a kernel configuration problem, but I doubt that is true as you are using the Mint-supplied kernel. or a systemd problem.

  • luisviveropena
    luisviveropena Posts: 1,249

    Hi @herecomesbrod ,

    I don't have any Mint system, but I have Ubuntu 18.04, and it looks like it's kind of similar to your distro (somewhere in the middle of your Mint version).

    So, with the new udev rule in place, when you connect a usb device, you will be able to see the value you specified in the "SYMLINK+=" parameter, as here:

    luis@ubuntu18server:/etc/udev/rules.d$ ls -l /dev/myusb
    lrwxrwxrwx 1 root root 15 Kun 24 10:45 /dev/myusb -> bus/usb/001/003

    Then you unmount the usb device, remove the udev rule, and connect the usb device again. This time you won't get any "myusb" device on /dev/ :

    luis@ubuntu18server:/etc/udev/rules.d$ ls -l /dev/my*
    ls: cannot access '/dev/my*': No such file or directory

    I hope that helps.

    Regards,
    Luis.

  • Thanks for your response Luis.

    I have already done what you suggested, but it doesn't work. Please see the following. Note that the USB stick is identified as sdc1:

    steve@ZeroGravitas:/etc/udev/rules.d$ ls -l /dev/sd*
    brw-rw---- 1 root disk 8, 0 Jul 24 17:53 /dev/sda
    brw-rw---- 1 root disk 8, 1 Jul 24 17:54 /dev/sda1
    brw-rw---- 1 root disk 8, 10 Jul 24 17:54 /dev/sda10
    brw-rw---- 1 root disk 8, 2 Jul 24 17:53 /dev/sda2
    brw-rw---- 1 root disk 8, 3 Jul 24 17:53 /dev/sda3
    brw-rw---- 1 root disk 8, 4 Jul 24 17:53 /dev/sda4
    brw-rw---- 1 root disk 8, 5 Jul 24 17:53 /dev/sda5
    brw-rw---- 1 root disk 8, 6 Jul 24 17:53 /dev/sda6
    brw-rw---- 1 root disk 8, 7 Jul 24 17:53 /dev/sda7
    brw-rw---- 1 root disk 8, 8 Jul 24 17:53 /dev/sda8
    brw-rw---- 1 root disk 8, 9 Jul 24 17:53 /dev/sda9
    brw-rw---- 1 root disk 8, 16 Jul 24 17:59 /dev/sdb
    steve@ZeroGravitas:/etc/udev/rules.d$
    steve@ZeroGravitas:/etc/udev/rules.d$ cat 80-usb_altname.rules
    SUBSYSTEM=="usb”, SYMLINK+=”myusb”
    < NOW I INSERT THE USB STICK >
    steve@ZeroGravitas:/etc/udev/rules.d$ ls -l /dev/sd*
    brw-rw---- 1 root disk 8, 0 Jul 24 17:53 /dev/sda
    brw-rw---- 1 root disk 8, 1 Jul 24 17:54 /dev/sda1
    brw-rw---- 1 root disk 8, 10 Jul 24 17:54 /dev/sda10
    brw-rw---- 1 root disk 8, 2 Jul 24 17:53 /dev/sda2
    brw-rw---- 1 root disk 8, 3 Jul 24 17:53 /dev/sda3
    brw-rw---- 1 root disk 8, 4 Jul 24 17:53 /dev/sda4
    brw-rw---- 1 root disk 8, 5 Jul 24 17:53 /dev/sda5
    brw-rw---- 1 root disk 8, 6 Jul 24 17:53 /dev/sda6
    brw-rw---- 1 root disk 8, 7 Jul 24 17:53 /dev/sda7
    brw-rw---- 1 root disk 8, 8 Jul 24 17:53 /dev/sda8
    brw-rw---- 1 root disk 8, 9 Jul 24 17:53 /dev/sda9
    brw-rw---- 1 root disk 8, 16 Jul 24 18:03 /dev/sdb
    brw-rw---- 1 root disk 8, 32 Jul 24 18:03 /dev/sdc
    brw-rw---- 1 root disk 8, 33 Jul 24 18:03 /dev/sdc1
    steve@ZeroGravitas:/etc/udev/rules.d$ ls -l /dev/myusb
    ls: cannot access '/dev/myusb': No such file or directory

  • luisviveropena
    luisviveropena Posts: 1,249
    edited July 2020

    Hi @herecomesbrod ,

    Please try naming the .rule file as follows: -.rules , in this case: 80-myusb.rules. I'm still researching on the need for this.

    Regards,
    Luis.

  • Hi Luis,

    I tried renaming the rules file to 80-myusb.rules as advised, rebooted and inserted the USB stick, but it still is not creating the symlink in /dev.

  • luisviveropena
    luisviveropena Posts: 1,249

    Hi @herecomesbrod ,

    That sounds weird, because I did exactly the same test case. The only last thing that comes to my mind, is to check the "udev" service, as it has to be running for this to work:

    luis@ubuntu18server:~$ sudo systemctl status udev
    ● systemd-udevd.service - udev Kernel Device Manager
    Loaded: loaded (/lib/systemd/system/systemd-udevd.service; static; vendor pres
    Active: active (running) since Sat 2020-07-25 14:32:42 -05; 1min 18s ago
    Docs: man:systemd-udevd.service(8)
    man:udev(7)
    Main PID: 315 (systemd-udevd)
    Status: "Processing with 10 children at max"
    Tasks: 1
    CGroup: /system.slice/systemd-udevd.service
    └─315 /lib/systemd/systemd-udevd

    Kun 25 14:32:42 ubuntu18server systemd[1]: Started udev Kernel Device Manager.
    Kun 25 14:32:46 ubuntu18server systemd-udevd[337]: link_config: autonegotiation i
    Kun 25 14:32:46 ubuntu18server mtp-probe[739]: checking bus 2, device 2: "/sys/de
    Kun 25 14:32:46 ubuntu18server mtp-probe[739]: bus: 2, device: 2 was not an MTP d
    Kun 25 14:32:48 ubuntu18server systemd-udevd[346]: link_config: autonegotiation i
    Kun 25 14:32:56 ubuntu18server systemd-udevd[1556]: link_config: autonegotiation
    Kun 25 14:32:56 ubuntu18server systemd-udevd[1555]: link_config: autonegotiation
    Kun 25 14:32:56 ubuntu18server systemd-udevd[1555]: Could not generate persistent
    Warning: Journal has been rotated since unit was started. [...]

    Regards,
    Luis.

  • coop
    coop Posts: 916

    minor point -- on RHEL you have to do "systemctl status systemd-udevd.service" (not just udevd) I really don't have an answer for why it works fine for me and Luis, it has something to do with your system setup or kernel.

  • I have found the problem.

    I used the od utility to check the contents of the rules file and found that some of the quote (") characters had a different character code:

    steve@ZeroGravitas:~$ od -c /etc/udev/rules.d/80-myusb.rules
    0000000 S U B S Y S T E M = = " u s b 342
    0000020 200 235 , S Y M L I N K + = 342 200 235
    0000040 m y u s b 342 200 235 \n \n
    0000052

    I deleted the text, retyped it and checked again:

    steve@ZeroGravitas:~$ od -c /etc/udev/rules.d/80-myusb.rules
    0000000 S U B S Y S T E M = = " u s b "
    0000020 , S Y M L I N K + = " m y u s
    0000040 b " \n \n
    0000044

    I restarted the udev service, plugged in the USB stick and the symlink appeared in /dev.

    Not sure how the weird characters got in the rules file - I use nano for editing.

    Thanks for your help.

  • coop
    coop Posts: 916

    This kind of thing can happen when people cut and paste from either pdfs or word processor documents like .docx or even google docs. If you typed it by hand, it falls in the realm of "some mysteries are not understood by modern science."

  • luisviveropena
    luisviveropena Posts: 1,249

    Oh, I remember I saw it many years ago when somebody copied a text on Windows. In fact I copied the text from the pdf file and I didn't hit the issue.

    I'm glad it's solved now :)

    Regards,
    Luis.

  • coop
    coop Posts: 916

    I don't know if we warn people enough in this course in the intro chapter, but cut and paste from pdfs causes countless problems and should be avoided by the plague. In particular quote characters (such as ' ") and the backquote (`) are often screwed up, and usually invisibly. NEVER DO THIS :) And it really does not have much to do with if it is coming from Windows are not, although it does depend on the pdf reader -- evince works much better than acroread which should never ever be used in any circumstance as it is rather defective, probably by design.

    We have had this problem repeatedly in many courses, especially the Kubernetes ones and no matter how much we tell people not to do this is a perpetual issue.

  • luisviveropena
    luisviveropena Posts: 1,249

    Oh, Acrobat Reader works worse because it hasn't been updated in many years for Linux. But yes, typing is large better. For other scenarios when the text is larger, let's say any yaml file, pasting it to a simple text editor and copying from there may help.

    Many regards,
    Luis.

  • coop
    coop Posts: 916

    I don't even know if it is possible to get acroread for Linux as there has been an updated version for years and Adobe itself does not provide it any more for download. I personally have not seen it anywhere for a long long time

    But Acrobat Reader is also defective in Windows at least as far as cut and paste goes. Do not use it for that purpose. To read documents fine, but that is all it is good for

  • Hi Luis and coop,

    I am aware of the problems with cut-and-paste from word processing applications, so wouldn't normally do that - maybe I just had a blank moment.

    FWIW I am not a fan of Adobe software, including Acrobat Reader, having spent many hours watching it install or update at the speed of grass growing and hoovering up system resources like it was on a supercomputer :-)

Categories

Upcoming Training