View previous topic :: View next topic |
Author |
Message |
cwc Veteran
Joined: 20 Mar 2006 Posts: 1402 Location: Tri-Cities, WA USA
|
Posted: Mon Dec 22, 2008 2:22 pm Post subject: automount usb device and add usb to user [SOLVED] |
|
|
I'd like to automount a usb device and add usb to a non-root user.
First: How do you make a usb group to add to a user?
Socond: What's the best howto to get help with automounting? _________________ Without diversity there can be no evolution:)
Last edited by cwc on Wed Dec 24, 2008 6:01 am; edited 1 time in total |
|
Back to top |
|
|
amdg n00b
Joined: 27 Oct 2008 Posts: 45
|
Posted: Mon Dec 22, 2008 4:19 pm Post subject: |
|
|
I got this from one of the udev tutorials floating around the net (will post the link if I can find it again). Drop this in /etc/udev/rules.d:
Code: | KERNEL=="sd[b-z]", NAME="%k", SYMLINK+="usb%m", GROUP="users", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[b-z][0-9]", SYMLINK+="usb%n", GROUP="users", 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]", PROGRAM=="/lib/udev/vol_id -t %N", RESULT=="vfat", RUN+="/bin/mount -t vfat -o rw,noauto,flush,quiet,nodev,nosuid,noexec,noatime,dmask=000,fmask=111 /dev/%k /mnt/usb%n", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mount -t auto -o rw,noauto,sync,dirsync,noexec,nodev,noatime /dev/%k /mnt/usb%n", OPTIONS="last_rule"
ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/umount -l /mnt/usb%n"
ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rmdir /mnt/usb%n", OPTIONS="last_rule" |
Name the file 10-automount-usb.rules or something. It doesn't matter what you call it as long as it ends with .rules and starts with a low number (so they get loaded before everything else).
You do have to adjust the KERNEL regex parameters above to match what your USB devices will be potentially named (i.e. it should read sd[c-z][0-9] if your devices start showing up as /dev/sdc and so forth). |
|
Back to top |
|
|
cwc Veteran
Joined: 20 Mar 2006 Posts: 1402 Location: Tri-Cities, WA USA
|
Posted: Mon Dec 22, 2008 4:21 pm Post subject: thank you |
|
|
I'll give this a try and let you know how it goes.
thank you! _________________ Without diversity there can be no evolution:) |
|
Back to top |
|
|
cwc Veteran
Joined: 20 Mar 2006 Posts: 1402 Location: Tri-Cities, WA USA
|
Posted: Tue Dec 23, 2008 5:46 am Post subject: |
|
|
Works great. Nice. I can even write to the usb drive.
The script that was provided creates a /mnt/usb1 directory.
I mount the usb flash drive at /mnt/usb1. I'm assuming the usb1 is due to the script.
I added this script to /etc/udev/rules.d
I did not have to modified my fstab to get this work:
/dev/sda1 /mnt/usb auto noauto,users,rw 0 0
Thanks _________________ Without diversity there can be no evolution:) |
|
Back to top |
|
|
lpgasparotto n00b
Joined: 29 Jan 2009 Posts: 12 Location: Buenos Aires, Argentina
|
Posted: Wed Feb 04, 2009 1:01 am Post subject: |
|
|
Hi,
The script also works great for me (I changed mnt for media) but when I try to unmount de pendrive I get this:
umount /media/usb1
umount: /media/usb1 is not in the fstab (and you are not root)
Then if I do:
sudo umount /media/usb1
It works!
I don't have that problem with CDs or DVDs.
I added my user to groups plugdev, users and usb.
I'd like to be able to umount usb storage devices as a user. Also I'd like xFce create an icon when an USB device is plugged in in the same way it happens with CD ROMs.
Thank you very much in advance. |
|
Back to top |
|
|
genmich Apprentice
Joined: 03 Apr 2003 Posts: 196
|
Posted: Fri Jun 12, 2009 9:58 am Post subject: |
|
|
How do I need to change the udev-rule to mount fully formated usb sticks (/dev/sdb/)? It seems to work only with /dev/sdbX instead of /dev/sdb |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|