From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason LeBrun Date: Wed, 22 Sep 2004 01:43:23 +0000 Subject: Auto-handling arbitrary USB mass storage devices Message-Id: <200409211843.23943.jason@jasonlebrun.info> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org I'd like to use udev/hotplug to automate the addition/removal of USB storage devices. I'm not sure of the best way to go about this, since these tools certainly provide more than one way to do it! Basically, I'd like to set things up once, and then have this to happen for any plugged usb-storage device: 1. When I plug in a device, a device node with a some friendly name, like the results of SYSFS{vendor} should get created in /dev. 2. Mount points should get automatically created somewhere, like in /mnt or /media. They should also have a similarly nice name. 3. A line should be added to fstab that corresponds to the new drive. 4. Optionally, the drive should be mounted right away. It *seems* like hotplug/udev should allow this to be easy, but here are the problems I'm having in each step: 1. I can't seem to use all of the SYSFS attributes. For example, SYSFS{product} won't return anything. Furthermore, the %s format specifier is not working quite properly. For example, I have an external USB HD with two partitions. If I use SYMLINK="%s{vendor}%n" in my rules file, I get in my /dev directory the following: lrwxrwxrwx 1 root root 4 Sep 21 18:34 1 -> sda1 lrwxrwxrwx 1 root root 4 Sep 21 18:34 2 -> sda2 lrwxrwxrwx 1 root root 4 Sep 21 18:34 WDC -> sda1 If I just use a hard coded version, SYMLINK="WDC%n", it comes up properly: lrwxrwxrwx 1 root root 4 Sep 21 18:36 WDC1 -> sda1 lrwxrwxrwx 1 root root 4 Sep 21 18:36 WDC2 -> sda2 2+3. I want to create mount points and fstab entries based on either a "friendly" SYSFS attribute, or the device link created in step 1. It seems to be that everything beyond step 1 should be done using the hotplug system. I have no idea how to get the information I need for my hotplug scripts, however. Is there any way for hotplug to get the info that it needs from udev? Also, I can't seem to get the REMOVE actions to do anything in either udev or hotplug. Any hints or suggestions for any of the above would be greatly appreciated! Thanks, Jason ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel