This is an account of my experiences getting my USB pen drives to work on my Debian system. It cost me quite a lot of work, so I though I might as well share my experiences. The solution doesn't look so complicated, but boy did it take me long to find this out. There really needs to be a package that does all this, but I'll have to leave that up to somebody with more time on his hands.
What I'm using:
All of this is on i686 hardware, but that shouldn't really matter. The major differences between your situation and mine is probably in the kernel. I'm using a custom-built non-modular kernel, so if you need to load modules on-demand, this page will not help you with that. This page *will* help you to get the basics working though.
Installing usb-mount should get you into the following situation: if you insert a usb-storage device and run usb-mount, it automatically gets mounted at a new directory called (mount point)/device-0, and if you remove the device and then run usb-mount, the directory (mount point)/device-0 will disappear. You need to get this working before you continue with the next steps.
pen 0 0 0 0 0 0 0 0 0 0 0
This directs the hotplug code to
execute the script /etc/hotplug/usb/pen each time a usb device is inserted. I'm pretty sure this could be narrowed down some more so that it is only called for usb-storage devices, but for now this will have to do.
#! /bin/bash USBMOUNT=/usr/local/bin/usb-mount # Unfortunately udev only creates the device nodes AFTER this script is run. # We sleep for 2 seconds in the background and then run usb-mount. This will # mount the device. (sleep 2 && $USBMOUNT) & # Install usb-mount as the script that is run when the device is removed. # This will automatically unmount the filesystem. ln -s $USBMOUNT $REMOVER
In this script, you must set USBMOUNT to the location of your installed usb-mount. Make the script executable, i.e. run:
chmod u+x /etc/hotplub/usb/pen
This should set you up with a working system. Inserting the usb-storage device should mount the device automatically (albeit with a delay of up to 10 seconds), and subsequently removing the device should unmount it.
NOTE: The hotplug version that
I'm using contains a bug that makes that the unmount script is not called. The cause of this bug is that it tries to calculate the name of the "removal script" from the kernel-supplied device name, which no longer exists when the device is already removed. If your device does not get removed after you unplug it, edit the file /etc/hotplug/usb.agent and check if it contains the lines:
if [ "$DEVPATH" != "" ]; then # probably, 2.6.x REMOVER=/var/run/usb/$(readlink -f $SYSFS/$DEVPATH | sed -e 's;/;%;g') elif [ "$DEVICE" != "" ]; then # 2.4.x? REMOVER=/var/run/usb/$(echo $DEVICE | sed -e 's;/;%;g') else # should not happen? REMOVER=/var/run/usb/$(echo "$INTERFACE/$PRODUCT/$TYPE" | sed -e 's;/;%;g') fi
Try commenting out the first three lines (by putting a # at the beginning of the line), and changing the fourth line to read "if" instead of "elif". That fixed it for me. This bug is supposed to be fixed in a more recent version of Debian's hotplug scripts, but I haven't seen the fix yet. I'll update this page when the fix comes
through.