# hotplug for normal users

## Loke

How to make hotplug mount usbfs with the correct permissions, so normal users can mount and unmount USB devices?

Ive got Freevo - freevo.sf.net - running on a standalone box, and it support a camera plugin. When I plug my camera in, it pops up in the menu (based on the lsusb ID), but since I run freevo as a normal user, Im not allowed to mount the camera.

Nor sudo or entry in fstab is sufficient for me, so alternate solutions would be great  :Smile: 

----------

## taskara

I think it's just permissions in your fstab file.. uid=1000 or something like that.. hang on.. that's for ntfs.. ahh.. I'm sure it's here in the forums somewhere.. try this thread

EDIT: sorry. just read fstab entries are no good for you.. ahh .. try the thread above anyhow.. soz..

----------

## Loke

But how am I able to solve this problem then? When I plug my camera in, it appears as /dev/sdb  (On /dev/sda Ive got a cardreader). If I then unplug my camera, and then plug it in again, it appears as /dev/sdc. So obviously I cant add an entry in /etc/fstab since I cant guarantee what ID devfs assigns to it. Imagine I had many more hotplug devices. Then there would be no way I could predict what /dev/sdX a certain device got assigned. 

Heeelp   :Shocked: 

----------

## taskara

unmount it before you unplug it and it should be re-detected as sdb

perhaps we are talking about two different things here.. hotplug is the daemon that detects your devices, and supermount is the app that mounts them automatically.

supermount will not work with a usb device I don't think, because supermount works on MEDIA, not a device.

ie, you put in a new cd, it mounts it.

but if you pull out the whole cdrom drive and plug it back in, of course that won't work.

that's what you are doing if you have a usb drive, you are not unplugging the media, you're unplugging the device.

so you can't use supermount with it, but you CAN mount it manually, and unmount it manually, and then unplug it, and when you plug it back in, it shoudl detect as sdb again.

so you will need an fstab entry

----------

## Loke

Pardon me if I sound like a jerk, but why are you talking about supermount? Ive never mentioned it, I dont want it, I dont need it and I dont use it hehe   :Smile: 

I know what supermount is and how it works. And it wont help me solve my problem. Actually, if I plug the camera in and without mounting it, remove it and plug it in again it will be /dev/sdc (being /dev/sdb previously). Perhaps hotplug think /dev/sdb is "occupied" (timeout?) after the removal of the usb-storage device, and assign it to /dev/sdc the next time.

Anyway, this cant be the way this works. What if I had 10 usb-storage devices, like a phone, camera, usb-pen etc etc.  and id want to mount these in /mnt/phone, /mnt/camera, /mnt/storage etc. How can you then specify an /etc/fstab entry for these items? You cant possibly know what /dev/sdX devfs assigns to the device youre plugging in next? 

So there has to be another solution than what we mention here, presumably based on the USB-ID from lsusb.

Edit: Sorry if Im bitching, but its frustrating to explain this problem since noone seems to understand the nature of my inquiry. I appreciate you trying to help  :Smile: 

----------

## taskara

yeah no worries, well I guess I don't have a solution for you.

lemme check on my system...

well it works just fine for me.

```
bash-2.05b$ ls -l /dev/sdd

lr-xr-xr-x    1 root     root           33 Feb  8 09:43 /dev/sdd -> scsi/host4/bus0/target0/lun0/disc

bash-2.05b$ ls -l /dev/sdd

ls: /dev/sdd: No such file or directory

bash-2.05b$ ls -l /dev/sdd

lr-xr-xr-x    1 root     root           33 Feb  8 09:43 /dev/sdd -> scsi/host5/bus0/target0/lun0/disc

bash-2.05b$ ls -l /dev/sdd

ls: /dev/sdd: No such file or directory

bash-2.05b$ ls -l /dev/sdd

lr-xr-xr-x    1 root     root           33 Feb  8 09:43 /dev/sdd -> scsi/host6/bus0/target0/lun0/disc

bash-2.05b$ 

```

there was a second delay between each unplug and rechecking if /dev/sdd existed.

so linux sees my device instantantly, assigns it to /dev/sdd, unplug it and instantly /dev/sdd is gone.

plug it back in straight away and instantly /dev/sdd is back.

sorry I can't help you. good luck!

----------

## Loke

Yes, but thats not _the_ problem! *sigh* What if you had more than 1 usb hotplug device? How would you solve it then? Say you have one phone and one camera, and theyre both using the usb-storage protocol, and youd want them appear in the local filesystem under /mnt/phone and /mnt/camera. (After all - you want to know if you are browsing the files on the phone or the camera)

Depending on which device you plug in first, it will appear under the mount point defined in conjunction with eg /dev/sda (whatever comes first). So if youve defined /mnt/camera as /dev/sda in your /etc/fstab and you plug in your phone - devfsd will assign it to the first available logical letter - which is /dev/sda. Because as far as devfsd is concerned, youve plugged in just another usb-storage device. And consequently it will be mounted on /mnt/camera and *NOT* /mnt/phone which would be the correct behaviour.

Perhaps you now understand the issue at hand, and why there has to be another way around this problem  :Smile: 

Edit: Actually, I think you just proved my point with ls output from your computer. As you can see, /dev/sdd does not contain the same hostX mapping (it clearly says host4, host5, host6 etc between each hotplug/removal) - so as far as devfsd is concerned you plugged in 3 different devices. Perhaps its easier to understand why Im frustrated now.

----------

## taskara

I understand. I have no idea how to help. good luck!

----------

## Vann

You might want to look into udev.  This is one of the problems with devfs it was created to solve.

----------

## el_compa

Try this page http://www.buberel.org/linux/usb-automounter.php. With udev working, you can check what device was plugged in and then mount it with the required parameters.

----------

## Loke

Ah, thanks for the feedback, guys. After this Ive been reading up on devfs / udev debate and it looks like devfs has designflaws regarding my issue described above. And it looks like devfs is being dumped from the kernel soon, too. Going from experimental to deprecated  :Laughing: 

el_compa: Do you need udev working if using the instructions in the url you posted? The author doesnt mention udev, so I was just wondering. To me it seems like hotplug has the functionality to recognize certain USB devices based on their USB-ID tag from lsusb, and take the appropriate action.

----------

