Page 2 of 9 FirstFirst 1234 ... LastLast
Results 11 to 20 of 84

Thread: Create your own udev rules to control removable devices

  1. #11
    Join Date
    Oct 2005
    Location
    Sydney
    Beans
    1,952
    Distro
    Kubuntu

    Re: Create your own udev rules to control removable devices

    Quote Originally Posted by EReckase
    I have a 512 MB Intelligent Stick USB drive that I want to use for my GnuPG keys. I want the USB drive to automatically be mounted at a known location every time it's plugged in, so that the GnuPG paths can stay fixed regardless of whether or not I plug in another device. This HOWTO worked great, except for one little detail...how can I make the USB drive automount now that I've set up a mount point for it? When I remove the drive, re-inserting it does not automount it like it did before I made the changes above. I'll happily install autofs if need be, but I could use some pointers (/me is a n00b).

    The one difference I had from your tutorial is that my external drive is formatted ext3 rather than vfat, so my mount line in fstab is
    Code:
    /dev/usbdevices/usb_gnupg  /media/usb_gnupg ext3 defaults,errors=remount-ro  0  0
    Regards, and thanks for the tutorial.
    Is that correct?
    You don't need autofs. If you are using the gnome-volume-manager (default Ubuntu/GNOME installation = yes), it should handle the automounting.

    All udev does is set the device node for the attached device, which you have done correctly if you can mount the USB via the new device node.

    Getting it to automount should really only be an issue with the /etc/fstab. The fact that it is ext3, should make this easier too. I always had major issues trying to automount FAT16 partitions in Breezy.

    ________________

    When the gnome-volume-manager finds a new device (courtesy of hotplug, hal and udev) it will mount it using its own method. What's special about the gnome-volume-manager is that it can mount a device without needing root privileges. Meaning it doesn't require sudo.

    If a line in the /etc/fstab has been specified, then that line takes precedence over the gnome-volume-manager's method. If this is the case, the line must allow for an ordinary user to mount the USB disc, or the gnome-volume-manager can't mount it automatically.

    That's the theory though It worked just now on a LiveCD, so I hope it works now for you.

    ________________

    First can you try commenting (adding a # sign) the USB entry in your /etc/fstab. Then try un-plugging/plugging in your USB disc.

    If this works, then we know that the gnome-volume-manager is functioning properly. All that is left is to uncomment (remove the #) and change the line in the fstab to inlucde the option user.

    This option allows the partition to be mounted by an ordinary user (no need for sudo)
    /dev/usbdevices/usb_gnupg /media/usb_gnupg ext3 user,suid,dev,exec,auto, async,errors=remount-ro 0 0
    Then try un-plugging/plugging in the USB.

    - I replaced the defaults option with suid,dev,exec,auto, async because the user option over-rides the defaults (the options in red). You can read more about these options, by using
    Code:
    man mount
    or going here

    Mount Man Page


    Fingers crossed.
    I bring Sutekh's gift of [Ubuntu] to all human life

  2. #12
    Join Date
    Apr 2006
    Location
    Peachtree City, GA
    Beans
    83
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: Create your own udev rules to control removable devices

    Quote Originally Posted by Sutekh
    The version of udev in Dapper doesn't seem to have or use udevstart. I ended up re-booting to affect the changes when I tried this in Dapper.

    I'm sure there must be another way though.
    I searched around and found out that
    Code:
    sudo /etc/init.d/udev restart
    will do the same thing.


    By the way, thanks for writing this up Sutekh, it's always nice to learn something!

  3. #13
    Join Date
    Oct 2005
    Location
    Sydney
    Beans
    1,952
    Distro
    Kubuntu

    Re: Create your own udev rules to control removable devices

    Quote Originally Posted by ash211
    I searched around and found out that
    Code:
    sudo /etc/init.d/udev restart
    will do the same thing.


    By the way, thanks for writing this up Sutekh, it's always nice to learn something!
    Ok that's great. Makes sense to have it there, along with countless others (gdm, powernowd, firestarter, etc)

    Thanks for pointing that out! I shall edit the original post and include that if I port this HOWTO for Dapper.

    I'm glad you found it useful!
    I bring Sutekh's gift of [Ubuntu] to all human life

  4. #14
    Join Date
    Apr 2006
    Location
    Belgium
    Beans
    49
    Distro
    Ubuntu 6.06

    Re: Create your own udev rules to control removable devices

    i rechecked this thread for the automount thingy which has been discussed here

    about the udev start i already knew, my problem, for which i had to reboot, was that udevinfo -p - blabla etc didnt work correctly, no matter what i tried and as i was sure i had it done before i just started after a clean startup

  5. #15
    Join Date
    Oct 2005
    Location
    Dallas, TX
    Beans
    172
    Distro
    Ubuntu 6.10 Edgy

    Re: Create your own udev rules to control removable devices

    Thanks! Fixed both that problem, and, with the MODE part in the rules, my problem with permissions on my flash drive. Only question is, is there a way to make the drive still automount with this, rather than having to do it manually? If not, it's only a minor annoyance, but that'd be awesome if there was. Thanks again.

    Nevermind, I just read the rest of the thread. Great stuff.
    Last edited by grsing; June 3rd, 2006 at 04:14 PM.

  6. #16
    Join Date
    Dec 2005
    Location
    Vienna, Austria
    Beans
    155
    Distro
    Ubuntu

    Re: Create your own udev rules to control removable devices

    Sutekh, you were so kind to point my attention to this HOWTO in the reply to the question I posted over in the "Video and Sound" forum.

    In the meantime I did a little research on the matter of "How do I swap the sound device?" ... seems as this isn't going to be as easy to solve as writing up a rule for automounts. Nailing the sound devices to a specific /dev/dsp|audio|mixer seems a lot more troublesome.

    I dug my way through the boot-process of Dapper to see where and why the sound devices get "mixed up" (Remember? Breezy, using hotplug for the job, initialized them the other, correct, way around) --- and after seven (7) hours I still have no clue why the usb headset gets initialized before the onboard ac97 codec.

    Maybe you, or anyone else, will happen to have an idea that'll lead the way to crack it down ...

    By looking at /var/log/udev (the log that gets written by udevmonitor) I clearly see that the usb-audio device gets initialized first (/dev/dsp|audo|mixer) - followed by the onboard audio (/dev/dsp1|audio1|mixer1).

    What I'm unable to grasp is -> where does the assignment of the device-nodes actually happen?

    The rules in /etc/udev/rules.d all look very nice - but which one of them does the job?

    20-names.rules seems to be the closest one, but by looking at the content the audio devices are listed in top of usb; so the onboard audio should be the first on the line (unless I'm terribly mistaken).

    So, the question is ...

    Does anyone know which udev rule is in charge of assigning the device-nodes (/dev/dsp, /dev/audio and /dev/mixer) to the hardware/driver?

    Having a starting point would surely help to dig further into it to get the problem solved.

    Thanks for any valueable ideas,
    Storm.

  7. #17
    Join Date
    Nov 2004
    Location
    The Rockies
    Beans
    79
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Create your own udev rules to control removable devices

    This has been a very useful how-to, thanks.

    I am having a bit of difficulty with something I'm trying to do, so I'm hoping to get a little more help.

    I used this how-to to get a Sandisk 1GB Cruzer mounting properly. Here's what I would like to do:

    I need to make sure that the Cruzer gets backed up to my HD each time it is unmounted. I am already backing it up when it mounts, using the RUN command and an ACTION of "add". I am trying to run a script when the ACTION is "remove", but that doesn't seem to happen. Here is my rules line for this:

    Code:
    BUS=="usb", SYSFS{product}=="Cruzer Mini", KERNEL=="sd?1",ACTION=="remove", RUN+="/usr/local/scripts/test.sh"
    The script referenced in this line is just to tell me if it is working. It isn't. The scripts exists there and runs ok on its own, but doesn't run on an umount of the Cruzer.

    Any thoughts? Thanks.

  8. #18
    Join Date
    Apr 2006
    Beans
    32
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: Create your own udev rules to control removable devices

    Hey - This was super helpful! Now my comp recognizes my flash drive the same way every time. One question, though, how do I make it work for two drives? Whenever I try to add an iPod too, the system doesn't recognize either drive properly any more. I tried two ways---adding another line for the iPod to the .rules file, and when that didn't work, adding a semicolon at the end of the line. No luck with that either. Thanks, though, this guide is just what I wanted.

  9. #19
    Join Date
    Oct 2005
    Location
    Southeast Asia
    Beans
    Hidden!
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: Create your own udev rules to control removable devices

    Hi and thank you for this tut. I wonder if this will fix my USB issues.

    I have a USB wlan stick and an ext USB drive. Every time i mount/dismount the ext drive, I loose the USB wlan device. Do you think this will help me from having to unplug and connect the USB wlan every time I mount/dismount the ext drive?

  10. #20
    Join Date
    Jul 2006
    Location
    Deep South Texas
    Beans
    311
    Distro
    Ubuntu

    Re: Create your own udev rules to control removable devices

    Unfortunately I read this HOWTO after I had solved my problem by another means. Now however, I'm wondering if the method I used is okay or if I just got lucky.

    I am using both an external USB hard-drive (160GB) and a USB thumb-drive (1GB). The contents of the hard-drive (I call it 'WD-160') are shared on my network via Samba whereas the contents of the thumb-drive (I call that 'WWMEM1G') are part of an encrypted file system. Thus it is important, regardless of the order in which they are inserted, that they always end up mounted at the same place, (and I wanted them each in their own root level folders, not in '/media').

    Both are formatted FAT32 and since I have used them both on a WIN XP system, I was able to label the drives as 'WD-160' and 'WWMEM1G'. I noticed that when mounted in '/media', folders were created with those names.

    In '/dev/disk/by-label' I found symbolic links having the same names and pointing to either '/dev/sda1' or '/dev/sdb1' depending on which order I had inserted them.

    In '/etc/fstab' I added mount directives for the devices '/dev/dis/by-label/WD-160' and '/dev/disk/by-label/WWMEM1G' specifying the desired mount points for each as well as the other usual parameters for FAT32 filesystems.

    Both filesystems now mount in the correct spot automatically. When they are inserted, (boot time or later), or the order of insertion does not seem to matter.

    In order for them to mount automatically, I had to set the 'Removable Drives and Media Preferences', (System > Preferences > Removable Drives and Media), with a check-mark in each of the first two boxes on the 'Storage' tab.

    It works fine but with all of my screwing around to get it to work I have ended up with duplicate icons on the desktop, (two for each of my devices when mounted). Any suggestions for how to get rid of the extras.

    (Please forgive my ignorance about all of this, I'm a Ubuntu/Linux newbie and until I read this howto I had never even heard of 'udev'.)

Page 2 of 9 FirstFirst 1234 ... 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
  •