LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-04-2008, 02:12 PM   #1
RAFAL
Member
 
Registered: Feb 2006
Location: Warsaw, Poland
Distribution: Archlinux, Debian
Posts: 139

Rep: Reputation: 16
mount USB drive as user


Hi,
I have some external USB drives (WD) which are not considered by system as removable. I have one with NTFS and two with FAT32.

When I try to mount I get error:

rafal@linux-39sr:~> mount /dev/sdb1 /mnt/usb1
mount: only root can do that

I know this was discussed several times, but no solution worked for me.
Here what didn't work:

1)
chmod +s /bin/mount
chmod +s /bin/umount

2)
giving sudo:
In YaST (I am using suse) I added my user option to execute /bin/mount, but it still does not work. maybe its about the access to /dev/sdb1 ?


I don't want to add any entry to /etc/fstab because I have several USB slots and disks. Some are NTFS, some FAT32. If I add entry in fstab then I never sure whether next time my sdb1 will be FAT32 or NTFS. It depends which drive I will connect as first (and maybe only one).

What I have to do in order to give access for my user to mount everything I want.

regards
Rafal
 
Old 11-04-2008, 05:42 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
There are various options I would try. First off, create an entry in fstab with the user option, but without the type specified.

Now since you specified user you should be able to mount it as a user, however you have not define the type yet.

Try:
-t autofs
-t vfat,ntfs (mount will try these in this order)
-t vfat (if you are sure it is vfat)
-t ntfs (likewise)

Reading thru man fstab I get the idea that other options are retrieved from fstab but that you are free to specify the type in the command.

jlinkels
 
Old 11-04-2008, 06:26 PM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
To resolve the problem where the same drive may have a different device node the next time you boot or plug it in, use the uuid or label instead of the device.

Suppose that the partition to mount is /dev/sdb. Then run "udevinfo -q env -n /dev/sdb". There will be a line like:
FS_UUID=ABC123-123432
Copy the UUID= and the number after it and paste it in the fstab entry in place of /dev/sdb.

For fat32 partitions, to be able to mount them as root, you need the "user" or "users" option and UID= and GID= options as well. Then a regular user can mount and unmount the partition. You can use either your username or your uid number.

The mount command is normally an suid program. It checks the mount options in /etc/fstab to determine whether a regular user will be allowed to use the command or not.
 
Old 11-05-2008, 03:37 PM   #4
RAFAL
Member
 
Registered: Feb 2006
Location: Warsaw, Poland
Distribution: Archlinux, Debian
Posts: 139

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by jschiwal View Post
Suppose that the partition to mount is /dev/sdb. Then run "udevinfo -q env -n /dev/sdb". There will be a line like:
FS_UUID=ABC123-123432
Copy the UUID= and the number after it and paste it in the fstab entry in place of /dev/sdb.
Hi
Thanks for advise.
I executed the command and added the line to /etc/fstab:

Code:
UUID=B06A38A66A386AEC /mnt/usb1   ntfs-3g    users,gid=users,locale=pl_PL.UTF-8 0 0

here the error I get:

Code:
rafal@linux-39sr:/mnt> mount /mnt/usb1
Error opening '/dev/sdb1': Brak dostępu
Failed to mount '/dev/sdb1': Brak dostępu
Please check '/dev/sdb1' and the ntfs-3g binary permissions,
and the mounting user ID. More explanation is provided at
http://ntfs-3g.org/support.html#unprivileged
"Brak dostępu" means "No access"
Only user 'root' have access to /dev/sdb1

Once I read I should add my user to group "disk' but it is not solution

So what can I do to get access to /dev/sda1.
chmod ?
I tested with "chmod 777" and afterwards get another error:

Code:
rafal@linux-39sr:/mnt> mount /mnt/usb1
ntfs-3g-mount: mount failed: Operacja niedozwolona
User doesn't have privilege to mount. For more information
please see: http://ntfs-3g.org/support.html#unprivileged
'Operacja niedozwolona" means "operation not permitted"

what will be clean solution here?

The reason why I need to mount device manually is that sometimes I'm using "Blackbox" as x-manager.

regards
Rafal
 
Old 11-05-2008, 05:00 PM   #5
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
modding /etc/fstab should be all you need to do.

Well, that and adding said user to the disk group.
And maybe chgrp the mount point.

/dev/uba1 /mnt/usb vfat user,noauto 0 0
/dev/sda1 /mnt/usb vfat user,noauto 0 0
/dev/sdf1 /mnt/usb vfat user,noauto 0 0

$ chgrp disk /mnt/usb

$ cat /etc/group | grep -i "disk"
disk:x:6:user

$ mount /mnt/usb

or

$ mount /dev/uba1
depending on which device or which usb port I use. Or if it's plugged in at boot time, versus inserted later. Check /proc/partitions to see what it registered as. (if it registered)

$ cat /proc/partitions

HTH
 
Old 11-06-2008, 02:57 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Adding a user to the disk group is a bad idea. That is the group owner of the raw devices as well. You want to grant access to one partiton, not all of them and not the raw devices (such as /dev/sdb) as well. Making a typo as a member of the disk group, you can wipe out any partition.

Read the web page that the error message points to. It gives solutions.
You can also use the ntfs filesystem. It might not work if the ntfs partition was formatted in vista and there are volume flags that aren't supported. Using these options, and the ntfs filesystem, I can mount it as a normal user:"rw,user,fmask=117,dmask=007,uid=jschiwal,gid=jschiwal"
However, due to unsupported features, it is mounted read-only.
 
Old 11-06-2008, 03:18 AM   #7
onesixtyfourth
LQ Newbie
 
Registered: Oct 2008
Posts: 9

Rep: Reputation: 0
This may be over simplistic and not what you need but could you install and use pmount?
 
Old 11-06-2008, 05:06 AM   #8
tothzp
LQ Newbie
 
Registered: Apr 2006
Posts: 26

Rep: Reputation: 17
Quote:
UUID=B06A38A66A386AEC /mnt/usb1 ntfs-3g users,gid=users,locale=pl_PL.UTF-8 0 0
Sorry but shouldn't the option be user instead of users ?

man mount says:

Quote:
(iii) Normally, only the superuser can mount file systems. However, when fstab contains the user option on a line, then anybody can mount the corresponding system.
Another solution would be to mount your disk via autofs. Then mounting is automatic and you can set an umask to give permission to others.
 
Old 11-09-2008, 02:19 AM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
The "users" option is similar to the "user" option. Using "users" any user can umount it. Maybe "user" would be a better option. There is also the "owner" option. Even if a different user mounts a fat32 partition, the uid=, gid=, fmask= and dmask= options will determine whether that user can read or write.

Use fmask and dmask instead of simply umask. You don't want the files to have the "x" bit set. You need the directories to have the "x" bit set. The "x" bit has different uses for files & directories so you need to use fmask & dmask instead.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cant do "mount/umount" on USB flash drive as regular user Salgeras Slackware 5 11-01-2007 08:09 PM
when i mount my USB Flash Drive A Messenge has come that mount: can't find /dev/sda/h feda82 Red Hat 2 12-24-2005 07:16 AM
when i mount my USB Flash Drive A Messenge has come that mount: can't find /dev/sda/h feda82 Red Hat 1 12-24-2005 04:25 AM
when i mount my USB Flash Drive A Messenge has come that mount: can't find /dev/sda/h feda82 Red Hat 2 12-24-2005 02:15 AM
mount usb module then mount usb hard drive guanyu Linux - Hardware 1 10-08-2003 11:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration