Score:0

/etc/fstab mount as user?

tw flag

Good Morning all,

When I use my fstab command below, it seems to be mounting the directory as root causing me to be unable to edit anything:

192.168.1.74:/volume1/Barry/Plex/tv2  /mnt/plex/media/tv2  nfs  nofail,defaults,rw,user, 0  0

192.168.1.74:/volume2/Barry2/Plex/tv  /mnt/plex/media/tv2  nfs  nofail,defaults,rw,user, 0  0


dandy@thehost:/mnt/plex/media$ ls -l
drwxrwxrwx  74  1024 users  36864 Jul  8 18:49 tv
drwxrwxrwx  13 root  root   36864 Jul  2 16:38 tv2

dandy@thehost:/mnt/plex/media$ sudo chown dandy:dandy tv2
chown: changing ownership of 'tv2': Operation not permitted

Could someone advise what I'm doing wrong?

Thank you

-- Edit --

I am currently using the following version:

Distributor ID: Ubuntu Description: Ubuntu 22.04.2 LTS Release: 22.04 Codename: jammy

Looking into the NFS3 this does sound interesting, however I'm unsure if I need to add the UID into the line suggested below.

192.168.1.74:/volume1/Barry/Plex/tv2 *(rw,no_subtree_check,all_squash,anonid=0,anaongid=0)

I've tried to run the command:

'sudo mount 192.168.1.74:/volume1/Barry/Plex/tv /home/dandy/mnt/media/tv *(rw,no_subtree_check,all_squash,anonid=0,anaongid=0)' but I get 'mount: bad usage '

Thank you for all of your help and I'm sorry I've been a nuisance.

-- edit

Not sure how to resolve post but Marco - thank you, that resolved it.

mook765 avatar
cn flag
Please don't post [duplicates](https://askubuntu.com/q/1477095/590937) of your own questions. Instead, edit your question to add information or improve it otherwise. Editing your question will bump it to the top of the homepage so it will attract viewers as same as a new question.You may need to be patient until you receive an answer, please remind that users are everywhere in the world and when you are awake, the one who can help you may need to sleep.
Dan Daley avatar
tw flag
Apologies, I will remember to include OS/release details in future. hello mook765, I will remember this, apologies didn't mean to cause any issues. Thank you
Luuk avatar
cn flag
@DanDaley: You did not find the [edit] button yet? It is there to add some (requested) info to your question.
Dan Daley avatar
tw flag
Luuk, I was trying to find out how to find the version. Please bear with me I'm new to Ubuntu and forums.
Luuk avatar
cn flag
When you have another question, you should create it. Please read [How to ask](https://askubuntu.com/help/how-to-ask) before doing so, and the links in that article..
Dan Daley avatar
tw flag
Thank you Luuk, I've got that bookmarked now.
mook765 avatar
cn flag
@DanDaley The best way to resolve the post is to [accept the answer](https://meta.askubuntu.com/a/1141/590937) that was helpful for you.
Dan Daley avatar
tw flag
Thank you mook :)
Score:0
br flag

With NFS the server takes care about the security. There are several levels and several security settings.

A level on the server is exporting it read-only. Which can not be changed on the client.

With NFS v3 the security is handled according the user id (number).
This means the userids on the client must be the same as on the server. The root user on the client is handled differently. By default user "0" (root) is mapped to user "nobody" on the server. Which usually give no access to user root. Server settings can change this behavior.
In your case the user "dandy" needs to have the same userid on the client and server to let user "dandy" read-write to all files/dirs belonging to user "dandy" on the server.

With NFS v4 there are more security options, which can be set on the server.
By default it is the same as in NFS v3, plus some with "Kerberos" which is usually not used, because it needs additional know-how and configuration.

See man nfs and man exports

Reminder: in a network environment you need security even if it takes additional effort.

Of course with the right settings on the server, you can disable all security and let everybody read-write, by adding this options on the server in the corresponding "exports" file (with your example):

NFS v3:

/volume1/Barry/Plex/tv2 *(rw,no_subtree_check,all_squash,anonid=0,anaongid=0)

NFS v4

/volume1/Barry/Plex/tv2 *(rw,sec=sys,no_subtree_check,all_squash,anonid=0,anaongid=0)

Be aware, this gives everybody who can mount it full read-write access as user "root".

On the client you can use (according your example):

sudo mount 192.168.1.74:/volume1/Barry/Plex/tv2  /mnt/plex/media/tv2

or in "/etc/fstab":

192.168.1.74:/volume1/Barry/Plex/tv2  /mnt/plex/media/tv2  nfs  nofail,defaults,rw,user 0  0
Dan Daley avatar
tw flag
Hello, thank you for responding, I think NFS v3 is my way to go. However, do I still need the ip address at the beginning ( 192.168.1.74:/volume1/Barry/Plex/tv2 *(rw,no_subtree_check,all_squash,anonid=0,anaongid=0) ) Apologies, additionally, you mention 'By default user "0" (root) is mapped to user "nobody" on the server' does this mean that the 'anonid=0 needs to be changed to my ID? I believe it's 1000
Marco avatar
br flag
You are mixing server and client configuration. Server config see `man exports` client config see `man nfs`.
Dan Daley avatar
tw flag
Hello Marco, thank you for responding, I've tried to run that and get 'no manual entry' for exports or nfs. I get what you mean now though. But I seem to get 'bad mount' when I try to mount the above.
Marco avatar
br flag
Strange system. The manuals are provided in the packages "nfs-kernel-server" and "nfs-common" which are needed to work with nfs. Without you can not export or mount nfs.
Marco avatar
br flag
In your case from a security aspect there is only a small difference between "anonid=0" and "anonid=1000". Both settings let everybody read-write your files.
Dan Daley avatar
tw flag
Hello Marco, thank you for your continous support here. I ran the command in terminal but getting 'mount: bad usage' -- Ignore I've seen your edit :)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.