You are not logged in.

#1 2009-05-14 03:56:25

lithium
Member
Registered: 2007-09-18
Posts: 76

AutoFS USB Devices

Hello,

Is it possible to have autofs automount devices for which you don't know the /dev entry or the UUID. For example, if I have a lot of different usb drives. I don't want to go looking for all of the UUID's or try to know where each one will be mapped. I'd like to be able to simply plug in the drive and have autofs create some directory in /media with the drive contents. I believe that GNOME/KDE can do something like this, so that the drive just appears as a new folder on one's desktop. However, I would like this to work in the console as well (and I use OpenBox).

It seems like it should be simple but I've been searching google, the forums and the wiki for a few hours now but I can't seem to find this. Everything I've found relates to automounting a device that you already know about.

Thanks.

Offline

#2 2009-05-14 12:07:37

scv5
Member
Registered: 2008-10-19
Posts: 109

Re: AutoFS USB Devices

Using pcmanfm (or another graphical file manager) the drives simply show up in the volume listing on the left hand column for me, and mere clicking on them mounts them into /media/<device name>

Though I'm not entirely sure what service is responsible for that.  I think HAL?

Offline

#3 2009-05-14 12:44:20

hbekel
Member
Registered: 2008-10-04
Posts: 311

Re: AutoFS USB Devices

udev rule:

SUBSYSTEMS=="usb", KERNEL=="sd*", SYMLINK+="usb-drive%n"

/etc/autofs/auto.media entry:

usb -fstype=auto,sync,users,uid=1000,gid=1000,umask=002 :/dev/usb-drive1

This should create /dev/usb-drive if you plug in a drive, and automount it on /media/usb upon access.

Offline

#4 2009-05-14 18:46:18

lithium
Member
Registered: 2007-09-18
Posts: 76

Re: AutoFS USB Devices

Actually, it turns out I can do this without AutoFS, only with udev. I added the following to a new file called /etc/udev/rules.d/10-automount.rules:

SUBSYSTEM=="usb", KERNEL=="sd[b-z]", NAME="%k", SYMLINK+="usb%m", GROUP="storage"
ACTION=="add", KERNEL=="sd[b-z][0-9]", SYMLINK+="usb%n", GROUP="storage", NAME="%k"
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mkdir -p /mnt/usb%n"
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mount -t auto -o rw,group,users /dev/%k /mnt/usb%n"
ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rmdir /mnt/usb%n"

A new /mnt/usb%n folder is created for each usb device. Any idea on how I would get this folder to be readable/writable by members of the storage group. Also, members of this group should be able to unmount the folder. However, I don't want any auto-unmounting to take place.

Thanks.

Last edited by lithium (2009-05-14 19:03:19)

Offline

#5 2009-05-14 19:39:47

lithium
Member
Registered: 2007-09-18
Posts: 76

Re: AutoFS USB Devices

UPDATE: I am able to get the mounted folder writeable by storage group members by passing gid=storage,umask=002 to the mount command. But those are fat specific options. Users still cannot umount.

This brings me to a more general point, independent of udev. Is it possible to mount something as root (regardless of the filesystem) such that any user in a given group may read and write to the mount point as well as umount it? All this WITHOUT an entry in fstab?

Last edited by lithium (2009-05-14 19:40:04)

Offline

Board footer

Powered by FluxBB