LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-06-2012, 12:36 AM   #1
suraj278
LQ Newbie
 
Registered: Mar 2012
Posts: 2

Rep: Reputation: Disabled
NFS setup to access directory from a remote machine as non-root user


I'm trying to setup NFS so that a linux user (non-root) can mount a directory of another machine(server) with read/write permissions.

Let say, I have a directory named "storage" on server(192.168.50.100) which will be exported and a host with IP address 192.168.50.60 should mount that directory in a local linux user account.

The details I used,

On server machine (/etc/exports)
/storage 192.168.50.60(rw,sync)

On host (/etc/fstab)
192.168.50.100:/storage /demo nfs defaults 0 1

[admin@suraj demo]# mount 192.168.50.100:/storage .
mount: only root can do that

So, I tried to login with root
[root@suraj demo]# mount 192.168.50.100:/storage .

>> directory is mounted. And I re-login into "admin" user account to create a file. But it says read-only.

[admin@suraj demo]# vi hello
[readonly]

I'm able to mount and edit files if I'm mounting in "root" account. But unable to mount in "admin" linux user account and perform read/write/execute operations. Can someone help me how to edit configurations to mount and have read-write permissions for local linux user instead of root.

Last edited by suraj278; 03-06-2012 at 12:41 AM.
 
Old 03-06-2012, 12:47 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello and welcome to LinuxQuestions,

If you want a user to be able to mount a partition/share to a mountpoint you'll need to add the user parameter to the mountpoint in /etc/fstab. Have a look at
Code:
man fstab
Next, check the permissions on the directory where you're mounting the NFS share. And on the NFS server side add
Code:
no_subtree_check,no_root_squash
to the export in /etc/exports (read man page for details), then run
Code:
exportfs -a
and try again. Let us know if you encounter errors.

Looking forward to your participation in the forums. Have fun with Linux.

Kind regards,

Eric
 
Old 03-06-2012, 03:26 AM   #3
suraj278
LQ Newbie
 
Registered: Mar 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks Eric for the reply.

On the server there will be no user called "admin" and I'm creating "storage" folder in "/". So, its permissions are uid=root and gid=root.Now, from client machine when I log in as root and create a mount point folder called "demo", it has permissions uid=root and gid=root and I feel this is the reason, it allows me to mount and create files in mount directory. But how do I achieve the same with local linux user say "admin" ? Even if I create a folder "demo" in admin userspace, initially its permissions are uid=admin and gid=admin. And now when I try to mount it says "only root can do mount". So, I did sudo su and then mounted the directory to my mountpoint and now the "demo" permissions changed to uid=root and gid="root" and gives me "readonly" when I switch back to "admin" space.

I have tried giving
In /etc/exports:
/storage 192.168.50.100(rw,sync,no_subtree_check,no_root_squash)
> exportfs -a

On client (/etc/fstab):
192.168.50.60:/storage /home/admin/demo nfs defaults,user 0 1

Still I can't do mount from "admin" account.
 
Old 03-06-2012, 09:00 PM   #4
saifelyzal
LQ Newbie
 
Registered: Jun 2011
Distribution: Redhat
Posts: 28

Rep: Reputation: Disabled
Hi
as far i know any nfs mounted its inherited permission from the server, you may need to check what permission on the server side.
and also you you can solve you problem with autofs by using autofs no need for the any users to use mount and it simply it available on demand
 
  


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
[SOLVED] Creating local NFS mounted home directory for remote LDAP authenticated user someshpr Linux - Newbie 2 12-15-2009 06:14 PM
How to create SSH user without access to root directory victorsk Linux - Networking 1 08-07-2009 06:56 PM
NFS non root user don't have write access. knockout_artist Linux - Newbie 1 10-10-2008 02:44 PM
can not access directory from user account - only root walterbyrd Linux - General 1 03-04-2005 11:23 PM
no-root user can not mount a remote nfs directory? xiamw Linux - General 3 12-16-2004 09:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:42 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