Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2006
    under the bridge

    Lightbulb Clearing doubts: udev/hotplug/autofs

    This is for learnig purposes...

    To all those who have been using slackware... Please help with links, comments of experience, scripts, config-files, etc... about /udev/hotplug/autofs

    This is intended to be a forum-howto, like this, we all will be able to become experts...

    Collaborate with your knowledge and XP.....

  2. #2
    ew , XP as a shortcut for experience

    I use hotplug, udev, and autofs for my ipod, memory stick, camera, and other things

    they are three seperate things, not really related.

    hotplug takes care of finding out when you plugged in a device, it'll then do what it can to load the correct module so the hardware will work.

    udev will dynamically create the device nodes based on rules, as /dev/ is usually a static directory, unless you use a dynamic device approach i.e udev or devfs, devfs is dead as a duck and has been superceded by udev. you can create rules so that your ipod comes up as /dev/ipod, or your camera /dev/camera, as I have.

    finally, autofs will automatically mount a device when its being used, or a samba/nfs share, even ftp. when you access a mountpoint that autofs (or more correctly automount) is governing, it will automount that device and you'll see your files without having to type any mount commands, after a specific timeout period it will unmount the device.

    you can see how good this is for removable storage, I plug my ipod or usb pendrive in, hotplug loads the correct modules, udev dynamically creates device nodes in /dev/ for it, and when I go into the directory /mnt/ipod, the device is mounted automatically and theres my files. when I finish using it , I simply unplug it and the device node dissapears.

    saves typing all those mounting comands, also, another advantage is that if you have varying amounts of devices plugged in, USB and firewire devices use SCSI emulation as sorts, they attach to the /dev/sd{a,b,c,d,e,x} interfaces, this means you can never setup the correct /etc/fstab rules, because what happens if you set a rule for /dev/sda1 in your fstab , then you decide to plug a usb device in such as an ipod, which needs /dev/sda2 mounted , not /dev/sda1

    basically if you use udev and plug your ipod in, you can set it to have the same device every time you plug it in, this way you can then write static fstab rules for devices such as /dev/ipod, /dev/camera, /dev/cardreader, and not /dev/sda1, /dev/sdb1, because if you did that and you plug the devices in a different order next time, the first device will be /dev/sda1, the second /dev/sdb, it all depends on the order you would have plugged them in.

    mind you , saying that my udev rules havent worked since I upgraded to the new udev that comes with slackware 11.0 and its refusing to create my device nodes dynamically.

    its not an easy task but once it all works its just like *cough* windows, where you plug in a device, use it, then unplug it.

    by the way, my cdrom and floppy drive are also automounted so that when I put a floppy or a cdrom in , I can just see the files, just like *cough* windows.

    I also have samba and NFS shares automounted so I never need to use smbclient or smbmount again. yay

    I hope this helps a little at least.

  3. #3
    Just Joined!
    Join Date
    Nov 2006
    under the bridge

    Thumbs up Cool

    Intersting comments.....
    If you can add some lines from your config files would be perfect..
    Also, I will try this kind of configuration on my slackware 11.. to see how it goes... and complete this forum-howto.

    Please somebody who knows something about this, share it......
    (links,comments,config files,etc...)

  4. $spacer_open
  5. #4
    I'll try add an example for a USB pendrive, for a start.

    Basically its a multi-step process, ensuring hotplug loads the device module, which is usually automatic, not much configuration here if any, as long as your mass-storage device is supported. The next step is to get udev to print out information from sysfs, mounted in /sys, you then take something from the information, such as the model number, or serial number of the device (preferable), then setup a udev rule to create a custom device node based on that key identifier, the serial number or whatever. once this is done, its best to test the device node can actually be mounted by setting up a test /etc/fstab rule, or possibly just try manually mounting it so you get a feel for the parameters. After this, finally you can setup autofs which loads as a kernel module, then configuring automount as a daemon which runs on boot, and has an automount config which tells it which directory to auto-mount which device node, and with which parameters. once one rule is working, others are quite easy.

    right, I don't have my configs at hand but I'll definately produce an example of getting a usb pendrive hotplugged and automounted when I get the config files to have a look at. some other members can critique my implementation of the udev rules (I think they are a bit off, I'm still a noob), and they can comment on how to correct them maybe.

    watch this space (hopefully), I hope the textual description helps though.

Posting Permissions

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