/etc/fstab mount as user?

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:  /mnt/plex/media/tv2  nfs  nofail,defaults,rw,user, 0  0  /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. *(rw,no_subtree_check,all_squash,anonid=0,anaongid=0)

I’ve tried to run the command:

‘sudo mount /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.

Asked By: Dan Daley


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  /mnt/plex/media/tv2

or in "/etc/fstab":  /mnt/plex/media/tv2  nfs  nofail,defaults,rw,user 0  0
Answered By: Marco
Categories: Answers Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.