Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 78996 - Hotplug not automounting usb devices at poweron with gentoo-dev-sources-2.6.10-r6
Summary: Hotplug not automounting usb devices at poweron with gentoo-dev-sources-2.6.1...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-21 13:11 UTC by Matthew Lane
Modified: 2005-01-23 13:49 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Lane 2005-01-21 13:11:02 UTC
The current version of Hotplug I use is: hotplug-20040923
This current version of the kernel I use is: gentoo-dev-sources-2.6.10-r6 
This bug was also present with: gentoo-dev-sources-2.6.10-r4



Reproducible: Always
Steps to Reproduce:
1.Install hotplug and gentoo-dev-sources-2.6.10-r6
2.Set up usb devices with device usermap and device script
3.Try and reboot/unplug/plugin devices, and they will not mount

Actual Results:  
The devices must be manually mounted instead with this kernel.

Expected Results:  
The drive should be automatically mounted at poweron and when the device is
plugged in.

This bug was not present with gentoo-dev-sources-2.6.9-r*

I use an external USB hard drive.  This is how I have it set up with hotplug:

I use these two files in /etc/hotplug/usb.
usbdrive.usermap - The usermap that identifies my drive.
usbdrive - A script that is called from above by hotplug.

usbdrive.usermap contains the following line:
usbdrive 0x0003 0x0402 0x5621 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000

usbdrive is marked executable with these contents:
#!/bin/sh

# NOTE: to make this work, you *MUST* use the options "sync" and "dirsync"
# in your /etc/fstab, otherwise you *WILL* lose data !!

N=0

while [ 100 -gt $N ] ; do
  if [ -e /dev/sda1 ]; then
    N=100
  fi
  sleep 1
  N=$(( $N + 1 ))
done

mount /mnt/usbdrive 2>/dev/null

#create a script to undo our actions upon removal
echo "#!/bin/bash" > $REMOVER
echo "fuser -m -k /mnt/usbdrive" >> $REMOVER
echo "sleep 3" >> $REMOVER
echo "umount /mnt/usbdrive" >> $REMOVER
chmod a+x $REMOVER
Comment 1 Daniel Drake (RETIRED) gentoo-dev 2005-01-21 14:05:16 UTC
hotplug doesnt do anything at bootup. it only responds to hotplug events.
If it doesn't work even when you hotplug the device, but it works manually, then it looks like there is something wrong with your script. By the way, udev would  be more appropriate for this sort of thing.
Comment 2 Matthew Lane 2005-01-21 14:40:43 UTC
Well, udev creates the proper devices at bootup.  /dev/sda and its partitions /dev/sda* are all visible.  And this bug did not exist until I upgraded to gentoo-dev-sources-2.6.10-r4 and gentoo-dev-sources-2.6.10-r6.  In fact, downgrading to the 2.6.9 series resolves this issue.  All my script does is wait for the device to be created and then it mounts it.  

Doing some further investigation, if the device is not currently mounted (or unmounted) and then un-plugged and plugged in, then my script automatically mounts it.  However, if it is mounted, and unplugged, it does not call my unmount script, the device is still mounted, and must be umounted as root because of this error message:  umount: /mnt/usbdrive mount disagrees with the fstab.

My connect and removal scripts worked flawlessly befor this series of the kernel.  I wonder if it is no longer generating the proper hotplug events for removal.  And yes, also prior to this kernel version, if the device was connected and powered on at bootup, then hotplug did mount it automatically.
Comment 3 Daniel Drake (RETIRED) gentoo-dev 2005-01-21 15:25:26 UTC
The hotplug system has changed somewhat recently. I still think udev is more appropriate for this task. Read the udev man page about dev.d
Comment 4 Matthew Lane 2005-01-21 16:17:34 UTC
Yeah, I see that.  But I think they may be used mainly for handling device names themselves.  I only have one script in there, and that is for net.  
I am using is udev-045.  I think these bugs can be renamed and reassigned, or should I recreate it and include udev in the title?
Comment 5 Daniel Drake (RETIRED) gentoo-dev 2005-01-21 16:56:58 UTC
The point is that its not a bug. Your script shouldnt get executed on bootup, and it doesn't. You can mount and unmount your device, thats also fine. Your own script isn't doing exactly what you want it to do, thats your problem, not ours :)

Unless I am missing something..?
Comment 6 Daniel Drake (RETIRED) gentoo-dev 2005-01-21 16:59:46 UTC
And I think you misunderstand the dev.d stuff. Its generally not used for handling device names. On my laptop, I have one in place where, when I plug my camera in, it mounts it, copies new photos to my disk, unmounts the drives, and beeps to signify that the camera can be unplugged. I based this off an example script I found somewhere which was basically an automounter like what you are trying to do.
Comment 7 Matthew Lane 2005-01-21 18:32:49 UTC
Well, I don't know.  Udev and hotplug have not been updated recently.  And as I said, this behavior ONLY happens when I use the latest kernel.  And in fact, when I boot into the previous one now, it works EXACTLY how I described. 

I constructed those scripts in accordance with the documentation over at http://linux-hotplug.sourceforge.net/ .  Hotplug is supposed to be notified of the hotplug event, then it looks at the usb.usermap file, and then executes the script specified in the usb.usermap file.  And that was changed in the specifications, so now the prefered way is to split each device into its own usermap file and script, like my usbdrive.usermap and usbdrive script.  This is one of the things that hotplug is used for afterall.

If you think this cannot be resolved with the kernel, I will repost this bug adding udev to the description.
Comment 8 Daniel Drake (RETIRED) gentoo-dev 2005-01-22 05:57:29 UTC
Hotplug is now doing what its supposed to. Yes, the behaviour has changed. No, thats not a bug.

Or are you saying, that even when hotplugging your device, your script doesnt get executed?

I also do not see why you think udev is related. Am I missing something?
Comment 9 Matthew Lane 2005-01-22 14:02:43 UTC
"By the way, udev would  be more appropriate for this sort of thing."

That's why I thought you wanted to include udev, also, I have been using it already.  

The script is not being called at bootup.  

It is called if the device is hotplugged.

It is not called if the device is unplugged (REMOVER).

The script was called at bootup with the previous kernel (and still is), if the behavior has changed, so be it.  I will explore alternatives.
Comment 10 Daniel Drake (RETIRED) gentoo-dev 2005-01-22 14:17:16 UTC
By the udev comment I meant you should drop your hotplug modifications and investigate udev as an alternative and better way of doing this, not that your issues are in any way related to udev. I'll mark this as invalid since I don't see any problems here.
Comment 11 Greg Kroah-Hartman (RETIRED) gentoo-dev 2005-01-22 21:52:05 UTC
Check that you are explicitly setting the file system type in your mount command.

I know this area of the kernel has changed, and for devices that would automatically be mounted as vfat, you now have to say "-t vfat" in your mount
command.

Odds are, that's the issue here.

And yes, you should use dev.d for this :)
Comment 12 Matthew Lane 2005-01-23 08:30:41 UTC
It was set to vfat in my fstab.  I tried IVMAN but couldn't get it to work correctly, so I went to autofs.  Now if they only fix that idle timer bug, I will be all set.  It takes care of my cdrom's too, and I didn't have to mess with the whole setting of device identifiers like I did with hotplug.  Besides, I had difficulty finding a howto on dev.d on the forums, so I went with autofs instead.
Comment 13 Matthew Lane 2005-01-23 13:49:56 UTC
Well, too late now to see if it is the problem, since I deleted my scripts (although I guess I did write them here...).  But I noticed that the hotplug startup script does nothing anymore, maybe it was because I wasn't using the coldplug package that it wasn't mounting at boot anymore.  Oh well.  Thanks for the advice though.