Mounting NAS, fstab, mount failed

I followed Swerdna’s guide to mount an NAS (on SuSE 11.4)

I added the following line to the beginning of /etc/fstab:

//192.168.1.130/nas /media/nas cifs credentials=/root/smb/credentials,_netdev,uid=userid,gid=users 0 0
(where userid is my username, the static IP and shared folder are correct, and /media/nas has been created)

I checked in system settings that smb was running under runlevels. I doubled checked the credentials file I created and the name of the shared file on the NAS.
I first got the error that only root could mount this, and then I got the error:

“An error occurred while accessing ‘nas on //192.168.1.130’, the system responded: mount: according to mtab, //192.168.1.130/nas/ is already mounted on /media/nas
mount failed”

I didn’t get any errors when running

# mount -a 

It seems that that the network folder is accessible via terminal (I could copy something into it), but not in the file manager Dolphin. Any tips or suggestions to resolve this?
Thanks in advance for any help.

Do not use directories inside* /media* for static mounted (via fstab) defined mounts. /media is for the dynamic mounts the system does for end-users when they insert media. From openSUSE 12.1 (well, not exactly that, but from a certain kernel) on, /media is a RAM mounted filesystem and thus vulnarable. In other words, your mount-point id gone after shutdown (and will not reuirn at boot).

Use some other mount point. Prefreable at the pint where you need that part of your directory tree, but when you have lack of imagination, you could go inside /mnt.

And of course mounts must ne done by root.

PS you apprently know how COPDE tags work. Why isn’t your fstab entry posted between them? And why not the error message?

Thanks for the reply. I’ll try for better formatting here. I think I’ve made a mess of things.
I first changed the mount directory unimaginatively to /mnt/nas, and got the following error:

An error occurred while accessing 'nas on //192.168.1.130', the system responded: mount: only root can mount //192.168.1.130/nas on /mnt/nas

I figured that fstab would mount it and setting the uid to user would allow me read/write access. Apparently more needs to be done. I searched around and found a similar thread on archlinux site, and followed their suggestion:

sudo chmod +s /sbin/mount.cifs
sudo chown *user*:users /mnt/nas
sudo chmod u=rwx,g=,o= /mnt/nas 

This didn’t work, but had the unfortunate side effect:


sudo mount -a
root's password:
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

mount -a
mount: only root can do that

I would like to use the NAS directory as a user and not just when signed in as root. I see some other suggestions online for this, but I think I need to resolve this issue first? Is this a result of the

sudo chmod +s /sbin/mount.cifs

?

sudo chmod +s /sbin/mount.cifs

You should never do things like this. You will bork your system meddling around with the security of your system tools.

I will be back, the lady of the hous calls me

This might be a bit diificult because IMHO you leave out a lot of information about what you do.

Where did you change that? In /etc.fstab, then please show this with

cat /etc/fstab

You got that error. What did you do when you got that error? Please complete descriptions and post complete from the terminal: prompt, command and output. Not jus part of it.

You seem to have a misconception here. fstab does not mount anything. It does not do anything. It is a configaration file, not a tool/program.
I told you allready that changing persmissions on system files is a certain way to brae your system. Thus my strong advise to undo asap the first statement with

chmod -s /sbin/mount.cifs

==============================
(BTW all these stments must be done as root. to become root do

su -

mind the - sign there, and to leave your root session type

exit

. Much easier then misusing sudo for a sequence ofstatements).

EDIT: Sorry I hit the send key to early. On to next post :frowning:

About the chown and chmod of /mnt/nas.
The ownership and permissioons of /mnt/nas should of course be set correct. But what is correct depends on what you are trying to achieve. That may be the most important thing that is missing here. What is your goal?
The fact that you can not mount has btw nothing to do with thses ownership/permissions. They only influence access after a successfull mount.

You seem to have a NAS that exports/shares file systems. Now, you did not tell, but from what you show I come to the conclusion that it shares with SAMBA and does not export with NFS (the latter is the standard Unix/Linux way of doing this).

I assume that you are aware that SAMBA exported shares are non-LINUX file systems (when mounted ) and thus have their limitations.

It is not complete clear to me if you want this share, when mounted, to be usable system wide (by all your users), or by one user only.

You also seem to be amazed by the fact that only root can mount. Of course, think about some silly user that mounts/unmounts all sorts of file systems at her/his own will.

Now my advice is that you post your* /etc/fstab* in the way I asked in the other thread and that you post then

mount /mnt/nas

(of course as root using su - as described above).

And then please do not go and consult all sorts of pages on the web and change things. You either try here in a way that you can follow our steps and we can follow your steps, or you go elsewhere. Jumping around and doing all things in a mix is a recipe for disaster.

The overall goal is to use a WD MyBookLive NAS to backup files periodically and store media. As far as SAMBA/NFS, there doesn’t seem to be any official linux support for this device, and other linux users online appear to set up some sort of SAMBA share with the device. Swerdna’s guide gave step by step instructions for such a setup, so I chose to follow it, but didn’t find a resolution to the mounting problem. If there’s another method without the limitations of samba, I’m all ears. For the time being, I only need this to be shared with one user when mounted, but that will soon change (any hopefully only require changing group/user priviliges I imagine?).

As for the code you asked for:

cat /etc/fstab
//192.168.1.130/nas /mnt/nas cifs credentials=/root/smb/credentials,_netdev,uid=aaa,gid=users 0 0
...

credentials are correct (triple and quadruple checked), folders exist, smb running.

# chmod -s /sbin/mount.cifs
# mount /mnt/nas
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

(****. this “permission denied” is all after having executed chmod +s /sbin/mount.cifs.)

As for the provenance of the following error message, it appeared in dolphin when I attempting to open the samba share configured in fstab.

An error occurred while accessing 'nas on //192.168.1.130', the system responded: mount: only root can mount //192.168.1.130/nas on /mnt/nas

On 2012-06-13 23:16, roidemai wrote:

> Code:
> --------------------
> cat /etc/fstab
> //192.168.1.130/nas /mnt/nas cifs credentials=/root/smb/credentials,_netdev,uid=aaa,gid=users 0 0
> …
>
> --------------------

For mounting as user you need to add the option “user” or “users”.

> Code:
> --------------------
> # chmod -s /sbin/mount.cifs
> # mount /mnt/nas
> mount error(13): Permission denied
> Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
>
> --------------------

I’m sure that there are some letters to the left of the ‘#’ - and they are
important. I can’t say what I think it might be because I’m not sure of
those letters.

Please, complete paste!


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Might you provide an example of how to alter the fstab entry for this option?

> Code:
> --------------------
> # chmod -s /sbin/mount.cifs
> # mount /mnt/nas
> mount error(13): Permission denied
> Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
>
> --------------------

I’m sure that there are some letters to the left of the ‘#’ - and they are
important. I can’t say what I think it might be because I’m not sure of
those letters.

Please, complete paste!


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

I’m very curious now why this is important…


linux-8nxi:/home/aaa # 

On 2012-06-14 05:36, roidemai wrote:
>
> robin_listas;2469230 Wrote:

>> For mounting as user you need to add the option “user” or “users”.
>
> Might you provide an example of how to alter the fstab entry for this
> option?


//192.168.1.130/nas /mnt/nas cifs
credentials=/root/smb/credentials,_netdev,uid=aaa,gid=users,user 0 0

> Code:
> --------------------
>
> linux-8nxi:/home/aaa #
> --------------------

Just what I thought! You are using “su”. You must use “su -” and try again.
Now guess how I know :wink:


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

How is this different than the fstab entry I had originally (gid=users)? I can’t find another example online of ‘gid=users,user’, and my username is part of the group ‘users’ already. I don’t have a group named ‘user’; was this meant to be renamed for some specific group I create?

Code:

linux-8nxi:/home/aaa #

Just what I thought! You are using “su”. You must use “su -” and try again.
Now guess how I know :wink:

su -
Password: 
linux-8nxi:~ # chmod -s /sbin/mount.cifs
linux-8nxi:~ # mount -a
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

This doesn’t seem to resolve the problem, unfortunately.

On 2012-06-14 17:06, roidemai wrote:
>
> robin_listas;2469290 Wrote:

> How is this different than the fstab entry I had originally
> (gid=users)? I can’t find another example online of ‘gid=users,user’,
> and my username is part of the group ‘users’ already. I don’t have a
> group named ‘user’; was this meant to be renamed for some specific group
> I create?

Read the man pages of fstab and mount :slight_smile:

The ‘user’ word I wrote there does not belong to the “gid=users” you wrote,
there is a comma separator. It is a separate option.

> This doesn’t seem to resolve the problem, unfortunately.

But have you modified fstab yet as I proposed?

The manual says:

+++····················
NOTES

This command may be used only by root, unless installed setuid, in
which case the noeexec and nosuid mount flags are enabled. When installed
as a setuid program, the program follows the conventions set forth by the
mount program for user mounts, with the added restriction that users must
be able to chdir() into the mountpoint prior to the mount in order to be
able to mount onto it.

····················+±

Is this done?


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Aha, okay! Ya entiendo.
Indeed I did make that correction to fstab, and then rebooted.


linux-8nxi:~ # cat /etc/fstab
//192.168.1.130/nas /mnt/nas cifs credentials=/root/smb/credentials,_netdev,uid=aaa,gid=users,user 0 0

When I try to select the NAS folder, dolphin gives me the error:

An error occurred while accessing 'nas on //192.168.1.130', the system responded: This program is not installed setuid root -  "user" CIFS mounts not supported.

Similarly,

su -
Password: 
linux-8nxi:~ # mount -a
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

Whereas previously, before I had ever issued the ‘chmod +s /sbin/mount.cifs’, I could execute ‘mount -a’ without any errors.

Thanks again for following me through this.

On 2012-06-14 20:26, roidemai wrote:
>
> Aha, okay! Ya entiendo.

Good :slight_smile:

> When I try to select the NAS folder, dolphin gives me the error:

Ignore dolphin, I can not help there

> Similarly,
>
>
> Code:
> --------------------
> su -
> Password:
> linux-8nxi:~ # mount -a
> mount error(13): Permission denied
> Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
>
> --------------------

So, the permissions there are wrong.

>
>
> Whereas previously, before I had ever issued the ‘chmod +s
> /sbin/mount.cifs’, I could execute ‘mount -a’ without any errors.

Well, paste here the permissions so that I can see them :slight_smile:


ls -l /sbin/mount.cifs

> Thanks again for following me through this.

Welcome :slight_smile:


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

On 2012-06-14 20:26, roidemai wrote:

> Code:
> --------------------
> su -
> Password:
> linux-8nxi:~ # mount -a
> mount error(13): Permission denied
> Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
>
> --------------------

I forgot. Don’t use “mount -a”, but “mount /mnt/nas” only.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Here you go:


linux-8nxi:~ # ls -l /sbin/mount.cifs
-rwxr-xr-x 1 root root 36504 Feb 19  2011 /sbin/mount.cifs
linux-8nxi:~ # mount /mnt/nas
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

On 2012-06-15 06:16, roidemai wrote:
>
> Here you go:
>
>
> Code:
> --------------------
>
> linux-8nxi:~ # ls -l /sbin/mount.cifs
> -rwxr-xr-x 1 root root 36504 Feb 19 2011 /sbin/mount.cifs
> linux-8nxi:~ # mount /mnt/nas
> mount error(13): Permission denied
> Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
>
> --------------------

Aha, it is not setup suid. You have to do the chmod thing again.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

I realy do not get this.

mount is executed by *root. *It calls mount.cifs which is accordingly also executed by *root. *What is the use of setting mount.cifs to suid root?

And when this should be the case, why isn’t it installed as such in the first place. Changing these settings is something I would not trust to be done by most Linux users. And it will be undone in any update. What is the idea behind this?

Like so?

linux-8nxi:~ # chmod +s /sbin/mount.cifs
linux-8nxi:~ # ls -l /sbin/mount.cifs
-rwsr-sr-x 1 root root 36504 Feb 19  2011 /sbin/mount.cifs
linux-8nxi:~ # mount /mnt/nas
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)


I rebooted as well after the chmod +s, just in case, but receive the same mount error.

On 2012-06-15 13:06, hcvv wrote:
>
> I realy do not get this.
>
> -mount- is executed by -root. -It calls -mount.cifs- which is
> accordingly also executed by -root. -What is the use of setting
> -mount.cifs- to -suid- -root?-

Good point indeed… :-?

> And when this should be the case, why isn’t it installed as such in the
> first place. Changing these settings is something I would not trust to
> be done by most Linux users. And it will be undone in any update. What
> is the idea behind this?

Because the manual says so, but you are right, for normal users. You can
restrict it to some users by removing permissions for “other” and joining
the “root” group.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)