Click to See Complete Forum and Search --> : Is hotplug not working properly?


hongman
04-23-2006, 08:29 AM
Hi all

When I boot up, I see the hotplug module loading.

But when I insert a USB key I have to mount the key manually.

Also, this next bit has always confused me.

Whenever I use a USB drive in linux, mounting and using it the first time is ok. If I then take it out and put it back in, it doesnt work. If I then try to umount and mount it back I just get "Device is busy" errors.

Thanks in advance

Hong

ladoga
04-23-2006, 09:22 AM
I don't think hotplug should automatically mount them unless you tell it to.

Quick search from google:
http://www.greenfly.org/tips/usb_drive.html

I always mount usb storages manually so i don't know how well that works. Maybe someone smarter than me will hop in and offer a better solution.

About your second question. Do you umount usb drive before removing it? Also make sure you're not accessing the drive (ie. don't have any of its directories open) when you try to umount it . That is usually causing those "device is busy" messages. You can ignore those by umounting with -l (lazy) flag though.

hongman
04-23-2006, 11:19 AM
Thanks ladoga

I wonder if there is a way of making hotplug handle USB devices completely automatically? i.e mounts it when its inserted, and automatically umounts them when removed.

Not too bothered by the shortcut on the desktop coz i normally use CLI anywyas...

ladoga
04-23-2006, 01:54 PM
I wonder if there is a way of making hotplug handle USB devices completely automatically? i.e mounts it when its inserted, and automatically umounts them when removed.

If i understood correctly thats what the link i posted above describes.

Same author has also an article about autofs, which you might find useful: http://www.greenfly.org/tips/autofs.html

Parcival
04-23-2006, 02:20 PM
Thanks ladoga

I wonder if there is a way of making hotplug handle USB devices completely automatically?

In my experience, SuSE is the only distro where this reliably works out of the box. My Kubuntu used to do it for a while (although with big delays in automatic mounting compared to the manual method) until it stopped to do that for some reason.

Gentoo has indepth documentation on USB and Linux, but so far I have been too lazy to read it completely. :)

ladoga
04-23-2006, 02:49 PM
What's the problem in using autofs like described in the link? :confused:

je_fro
04-23-2006, 03:14 PM
autofs is old and bloated...
and you'll ALWAYS have to unmount the USB drive before you can remove it safely.
new gnome and kde's should be able to handle what you're wanting without too much headache...just search.

bwkaz
04-23-2006, 03:20 PM
Mounting drives as they're inserted is not a job for either hotplug or udev, although you can configure udev to do it if you really need to. It's a job for HAL.

(That, I believe, is why SuSE works well with it -- SuSE probably runs HAL by default.)

From the udev FAQ (http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev-FAQ):

Q: Can I use udev to automount a USB device when I connect it?
A: Technically, yes, but udev is not intended for this. All major distributions
use HAL (http://freedesktop.org/wiki/Software_2fhal) for this, which also
watches devices with removable media and integrates into the desktop software.

Alternatively, it is easy to add the following to fstab:
/dev/disk/by-label/PENDRIVE /media/PENDRIVE vfat user,noauto 0 0

This means that users can access the device with:
$mount /media/PENDRIVE
and doen't have to be root, but will get full permissions on the device.
Using the persistent disk links (label, uuid) will always catch the
same device regardless of the actual kernel name. This assumes that your distro has set up udev rules to create /dev/disk/by-*/* symlinks for your disks and partitions; many recent distros do, but not all.

hongman
04-24-2006, 04:27 AM
Thanks, I'll test this today at some point.