LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   mounting usb as user (https://www.linuxquestions.org/questions/slackware-14/mounting-usb-as-user-4175507188/)

nass 06-05-2014 07:02 PM

mounting usb as user
 
Hi all,
I am trying to mount a usb as a simple user (who is a member of plugdev group and has inserted the mount command in the sudoers file).

The aim is to mount and umount a usb stick from the command line as a normal user and use it normally (read , modify , create new files etc).

If i type

sudo mount /dev/sdX1 /mnt/usbstick

I will get the device mounted without a problem but it is mounted as root:root and the permissions are 755, so I can not use the stick as expected ( I can not write to it ).

I need to either add the option umask=000 , or set a uid or set gid or a mixture of the above.
These all look somewhat ugly. Is there another way that I may be missing?

thank you for your help.

TracyTiger 06-05-2014 07:21 PM

fstab
 
Quote:

Originally Posted by nass (Post 5183224)
The aim is to mount and umount a usb stick from the command line as a normal user and use it normally (read , modify , create new files etc).

I have simple operations for USB storage devices. As a user I just plug in one flash drive at a time so I have the following in fstab. I created a directory /mnt/flash.

Code:

/dev/sdc1  /mnt/flash  auto  noauto,users  0 0
As a normal user I plug in the flash drive and type "mount /mnt/flash".

The option "users" allows a normal user to mount and any user to umount. You could also use "user" without the trailing 's' to restrict umount to only the user that mounted the device.

Occasionally I have to run as root to umount something when I unplug the flash drive without unmounting it first.

Most users want all of this to happen automatically no matter which device (/dev/sdxx) is used. Others on this forum would have to help with the automatic stuff (Which I turn off in Xfce).

EDIT: I ran "fdisk -l" (L) as root after plugging in the flash drive to find out the device (/dev/sdc1) that the flash drive would occupy.

maples 06-05-2014 08:58 PM

Try looking at pmount. It lets any user mount any removeable device in the /media directory. Example:
Code:

pmount sdb1
would mount /dev/sdb1 to /media/sdb1. It gives ownership to the user who ran the command. To unmount:
Code:

pumount sdb1
NOTE: If you are in the /media directory, and run the umount command above, it will attempt to run it on /media/sdb1, not /dev/sdb1. In that case, either cd out of /media or give the full path to /dev/sdb1.

Hope this helps!

elyk 06-05-2014 09:05 PM

This should do what you want: http://slackbuilds.org/repository/14.1/system/pmount/

`pmount /dev/sdX1` should mount it under /media/sdX1. Then use pumount as you would use umount.

The source download appears to be behind a login page, here's a mirror: http://ponce.cc/slackware/sources/re...0.9.23.tar.bz2


All times are GMT -5. The time now is 04:02 AM.