Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to mount a Windows ntfs partition on openSuse 11.4. When I mount it using the root account (either directly or via sudo) it mounts without problems. But when I try mounting it without any root privileges, it gives me the following error:

Error opening '/dev/sda2': Permission denied
Failed to mount '/dev/sda2': Permission denied
Please check '/dev/sda2' and the ntfs-3g binary permissions,
and the mounting user ID. More explanation is provided at
http://ntfs-3g.org/support.html#unprivileged

My fstab entry for the concerned device is:

/dev/sda2   /media/Windows      ntfs       defaults,noauto,user  1 2

I've searched Google for possible solutions, but I don't seem to be getting anywhere.

Edit 1:

As suggested, I tried to set the UID/GID bits on the ntfs-3g binary. All the files (/sbin/mount.ntfs, /sbin/mount.ntfs-3g) point to /usr/bin/ntfs-3g, so I changed the permissions on that. The permissions now are:

-rwsr-sr-x 1 root root 51512 Feb 18 22:18 ntfs-3g

But the result is still the same and I get the same permission denied error.

Edit 2:

After setting the correct permissions on all the files:

-rwsr-xr-x 1 root root 51512 Feb 18 22:18 ntfs-3g
brw-rw-rw- 1 root disk 8, 2 Aug  6 21:53 sda2
drwxrwxrwx 1 asad users 8192 Jul 30 13:09 Windows

I was able to mount with out a privileged user account. However, now when I try to unmount using the same account, I get:

asad@jb-laptop:~> umount /dev/sda2
umount: only root can unmount /dev/sda2 from /media/Windows

Edit 3:

I finally found the problem. I needed to add users instead of user in fstab for some reason, although I can't understand why. Now I have a new problem :)

Whenever I unmount the device /dev/sda2, somehow the file permission ends up going back to default (0660). I tried to create a rule in udev but it doesn't seem to be working.

share|improve this question
    
Please don't put the answer in your question. Your updates were good until the third one, that one you should add as an answer below. It's ok to answer your own question if nobody else has given the solution. If somebody has shown a partial solution you can comment on it or edit it to add whatever detail is missing. –  Caleb Aug 7 '11 at 7:02
    
Also, if you have a new question/problem please ask a new question. Each question answer set here should represent just one issue. Thanks for coming back and keeping everything up to date. –  Caleb Aug 7 '11 at 7:04
    
Thanks. :) I added the third update because I thought it was relevant to the problem, since after each unmount, the file permissions went back to default and the original problem surfaced. Perhaps I should have explained it a bit better in the last edit. –  Jibran Aug 7 '11 at 13:51
    
Make your posts informative for later usage -- what is your FINAL fstab entry? –  greenoldman Sep 10 '11 at 8:36
add comment

3 Answers

up vote 3 down vote accepted

The ntfs-3g binaries must be set uid root in order for user mounting to work. And you need permission to the block device & mount point.

sudo chmod 1755 /sbin/mount.ntfs-3g /usr/bin/ntfs-3g
sudo chmod 666 /dev/sda2
sudo chmod 777 /media/Windows

(Note: these are the Debian locations, they may differ for Suse, so you will want to check that they are actually in those locations.)

You also need to have ntfs-3g version 1.2506 or later.

See here for more info:

share|improve this answer
    
@jibran I expanded my answer with more info. –  bahamat Aug 6 '11 at 16:15
    
well, I'm halfway there. I've edited my answer to include the latest info. I'm hoping that you might be able to help me further. Thank you for all your help so far... –  Jibran Aug 6 '11 at 18:24
add comment

To solve similar problems in the future - especially with removable media (like USB disks), I'd recommend to use pmount for mounting filesystems as normal users. It uses a policy approach and saves you from doing system-wide changes, which can sometimes be dangerous (such as chmod 1755 /sbin/mount.ntfs-3g /usr/bin/ntfs-3g).

To make a specific local partition user-mountable via pmount, you can add it to a whitelist. In your case, this would mean

echo "/dev/sda2" >> /etc/pmount.allow

Which has to be run as root. (Or by editing the file: sudo nano /etc/pmount.allow)

share|improve this answer
    
thanks for the tip. I'll definitely look at pmount. Btw, is it possible to interface it with nautilus? After going through all this trouble, I can now mount from within nautilus without root access. Is it the same with pmount? –  Jibran Aug 7 '11 at 6:58
add comment

Solved It! Thank you @baharmat for all your help. If you hadn't pointed me in the right direction(s), I would still be facing the same issue. Here is how I did it.

As is apparent in my lengthy question, the only issue remaining was that for some reason the file permission of /dev/sda2 changed on unmount to the default of 0660. To fix that, I used the following udev rule:

KERNEL=="sda2", ACTION=="change", MODE="0666"
KERNEL=="sda2", ACTION=="add",    MODE="0666"

NOTE: The file /etc/udev/rules.d/81-mount.rules has ACTION=="add|change". That does not seem to work. I had to wrestle with the rule for more than an hour before I figured that one out. Any help would be appreciated concerning why a rule file that came with my distro contains something that does not seem to work.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.