Page 4 of 9 FirstFirst ... 23456 ... LastLast
Results 31 to 40 of 84

Thread: Create your own udev rules to control removable devices

  1. #31
    Join Date
    Jun 2007
    Beans
    55

    Re: Create your own udev rules to control removable devices

    is there any way to run a script in "/usr/local/zoobave" whenever a USB is plugged?

  2. #32
    Join Date
    Oct 2006
    Beans
    149

    Re: Create your own udev rules to control removable devices

    Yes there is! Just had RUN+="/usr/local/zoobave"

  3. #33
    Join Date
    Jan 2007
    Location
    Ridgeland WI US
    Beans
    464
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Create your own udev rules to control removable devices

    Thanks Sutekh,
    I had this problem:
    Home LAN - wife's laptop and my desktop.
    NFS file sharing
    New camera via USB, old camera's Compact Flash via a card reader USB.
    With Ubuntu 7.04 when I copied the files from the USB device the files were mode 711. When my wife connected to them she couldn't do anything with them.
    Now the two mount with names and mode 777. Thank again.
    I did have a couple of challenges following the steps though.
    Your: SYSFS{product}=="TS128MJFLASHA"
    for me was: ATTRS{product}=="NIKON DSC COOLPIX S4"
    also for BUS I needed SUBSYSTEMS
    Code:
    SUBSYSTEMS=="usb", ATTRS{product}=="NIKON DSC COOLPIX S4", KERNEL=="sd?1", NAME="Coolpix_S4", SYMLINK="usbdevices/Coolpix_S4"
    I also had the problem of not being allowed to mount the USB device after booting. So I adjusted /etc/fstab to add users like a previous post explained:
    Code:
    /dev/Coolpix_S4  /media/Coolpix_S4  vfat  iocharset=utf8,users,umask=000   0   0
    I also made the directories in /media
    $ sudo mkdir /media/Coolpix_S4
    Now I have mode 777 which I was seeking and the bonus of better names than disk and disk-1.
    I have not found what the last part of 10-local.rules does ... the SYMLINK=
    Last edited by ridgeland; August 3rd, 2007 at 04:11 AM. Reason: typo
    Gigabyte GA-MA790GPT-UD3H - AMD Phenom II x3 720 - 8 GB RAM - 2009 - My first PC from parts!

  4. #34
    Join Date
    Nov 2005
    Location
    Poland (Gdańsk)
    Beans
    143
    Distro
    Kubuntu 12.10 Quantal Quetzal

    Re: Create your own udev rules to control removable devices

    this how-to works fine on gusty

  5. #35
    Join Date
    Nov 2007
    Location
    Stamford, CT
    Beans
    6
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: Create your own udev rules to control removable devices

    I have a Sierra Wireless AC595U EVDO usb modem that I'm trying to write a rule for. When the device is connected, it creates 3 ttyUSB ports. i.e. ttyUSB0, ttyUSB1, ttyUSB2

    The actual "modem" port is always the first of the 3 to be created. What I would like to do is have a symlink to the first created ttyUSB port of this device, called "/dev/modem".

    To add additional complexity, I have other devices that are also recognized as ttyUSB devices, so I can't just create a symlink directly to /dev/ttyUSB0 and always have it work, since the 3-port USB modem may not have been inserted first.

    The basic rule I've been using is:
    KERNEL=="ttyUSB*", SYSFS{idVendor}=="1199", SYSFS{idProduct}=="0120", ACTION=="add", SYMLINK+="modem"

    The symlink *IS* created, but it is created for the last of the 3 ports, which is not useful.

    Using major/minor numbers of the device faces the same issue, so no luck there. Major number is always 188, but minor number depends on order of insertion of ttyUSB devices. (i.e. can't always depend on 188:0)

    udevinfo on each of the ports shows the same exact information as far as the physical device attributes are concerned. The only differences are the ttyUSB number, and the minor number of the device.

    Any ideas or suggestions on this?

  6. #36
    Join Date
    Nov 2007
    Location
    Stamford, CT
    Beans
    6
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Lightbulb Re: Create your own udev rules to control removable devices

    Here's the solution that I came up with for my own problem. When the AC595U USB modem is inserted, the SYSFS properties for vendor and product are checked, the new device is called ac595u0,1,2 (or whatever numbers are assigned). The modem.agent script runs with "add" as the argument, and a symlink is created from /dev/modem to whatever the first ac595u device is (ac595u0 if there are no other ttyUSB devices, but this will change if there *are* other ttyUSB devices).

    Upon removal (of any ttyUSB device), the modem.agent is executed with "del" as the argument and if no ac595u devices exist, the /dev/modem symlink is removed.


    my new udev rules:
    Code:
    KERNEL=="ttyUSB*", ACTION=="add", SYSFS{idVendor}=="1199", SYSFS{idProduct}=="0120", NAME="ac595u%n", RUN+="modem.agent add"
    
    KERNEL=="ttyUSB*", ACTION=="remove", RUN+="modem.agent del"

    The modem.agent script (lives in /lib/udev and must be executable):
    ** Note: to test this on the command line, change "print $10" to "print $9". For whatever reason, when using awk in a script called from udev, the argument list is increased by 1 **
    Code:
    #!/bin/bash
    
    if [ $# -gt 0 ]; then
            MODEM=`ls -l /dev/ac595u* | head -1 | awk '{ print $10 }'`
    
            if [ "$1" = "add" ]; then
                    if [ -n "$MODEM" ]; then
                            ln -sf $MODEM /dev/modem
                    fi
            elif [ "$1" = "del" ]; then
                    # ac595u device found?
                    if [ ! -n "$MODEM" ]; then
                            # device not found - check for modem symlink
                            if [ -L /dev/modem ]; then
                                    # remove link to modem
                                    rm /dev/modem
                            fi
                    fi
            fi
    fi

  7. #37
    Join Date
    May 2007
    Location
    Chennai,India
    Beans
    24
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Create your own udev rules to control removable devices

    When I use udev rules to execute a bash script it is executed more than once (7 times).Is there a way to stop it after the first time?

  8. #38
    Join Date
    Feb 2008
    Location
    Calgary
    Beans
    115
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: Create your own udev rules to control removable devices

    I just got an AFT-ZPO, a 6 in 1 Portable Flash Card Reader, and am trying to get it mounted to read flash cards for me. I tried following the tutorial but got lost part way through. Is it difficult to get a device like this mounted so that I can read flash cards?

    I'm running Gutsy.

    Thanks

  9. #39
    Join Date
    Feb 2008
    Location
    Calgary
    Beans
    115
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: Create your own udev rules to control removable devices

    More information on the device - it's from Atech Flash Technology Inc.

    Also, it appears attached to one of my USB 2 ports. I don't know how to access it though. That information came from the Device Manager.

  10. #40
    Join Date
    Jan 2007
    Location
    Ridgeland WI US
    Beans
    464
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Create your own udev rules to control removable devices

    Hi demarshall,

    Sounds like you're just trying to plug and play. You should not need to edit udev rules for that. Did simple tests work?
    Can you insert a card in the reader then plug the reader in and it auto mount itself?
    I always like to assume its a simple issue until I learn more. If you just plug it in (with a card in it) there should be a new icon on the desktop that you can just double-click and nautilus opens it to show you the contents. Does that work?
    Gigabyte GA-MA790GPT-UD3H - AMD Phenom II x3 720 - 8 GB RAM - 2009 - My first PC from parts!

Page 4 of 9 FirstFirst ... 23456 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •