10

I have an NFS_Server - NFS_Client system. My client is mounted to an NFS_Server directory. I want to change the attribute of NFS_Server directory's files via NFS_Client mounted directory by using Extended File Attributes (xattr).

When I tried to set an attribute from the client side, it gives the following answer:

root@ubuntu:/mnt/nfs/var/nfs# setfattr -n user.comment -v "some comment" test.txt setfattr: nfs.txt: Permission denied

My question is:

  • is it possible to use Extended File Attributes via NFS?

  • if possible, how can I do this?

UPDATE:

Server side:

$ more  /etc/exports file has:    
/var/nfs        192.168.56.123(rw,sync,no_subtree_check)

Client side:

$ root@ubuntu:/# mount -t nfs
192.168.56.130:/var/nfs on /mnt/nfs/var/nfs type nfs (rw,vers=4,addr=192.168.56.130,clientaddr=192.168.56.123)

thank you...

Celik
  • 1,825
  • 1
  • 25
  • 45
  • If you run that setfattr command as the owner of the file instead of root, do you get an error message? – Mark Plotnick Jul 08 '14 at 11:28
  • my owner is also root and it also gives the same error message. have you try this? what I want is possible or? – Celik Jul 08 '14 at 12:13
  • Can you include the export options you're using on the server and the mount options you're using on the client and the distro of the client and server? That will help us a lot. – Mark Plotnick Jul 08 '14 at 12:22
  • I added something on update part, are there what u want? – Celik Jul 08 '14 at 12:43
  • 1
    Do you do any NFS id mapping on the server? The configuration file for that is `/etc/idmapd.conf`. By default, an NFS server will translate `root` on the client to `nobody` on the server, which is why I think running `setfattr` as root might be getting a **permission denied** error. – Mark Plotnick Jul 08 '14 at 14:42
  • 1
    I'm very sorry, I thought your problem was just due to ID mapping, but it is more than that. It looks like Ubuntu's kernel does not support user xattr's on NFS filesystems. If you change your export options to include `no_root_squash`, which will allow `root` on the NFS client to be `root` on a server, the `setfattr` error message will change from **Permission denied** to **Operation not supported**. mount will accept an `acl` option but not a `user_xattr` option for an NFS filesystem. – Mark Plotnick Jul 08 '14 at 20:30
  • thanks you for your help... – Celik Jul 09 '14 at 05:19

3 Answers3

8

You can use fuse_xattrs (a fuse filesystem layer) to emulate extended attributes (xattrs) on NFS shares. Basically you have to do:

  1. mount the NFS share. e.g.: /mnt/shared_data
  2. mount the fuse xattr layer: $ fuse_xattrs /mnt/shared_data /mnt/shared_data_with_xattrs

Now all the files on /mnt/shared_data can be accessed on /mnt/shared_data_with_xattrs with xattrs support. The extended attributes will be stored on sidecar files. The extended attributes are not going to be stored on the server filesystem as extended attributes, they are going to be stored in sidecar files.

Sadly this is only a work-around.

disclaimer: I'm the author of fuse_xattrs.

fbarriga
  • 83
  • 1
  • 4
7

(This article is old, but I came across this article when looking for this functionality, and it doesn't represent the current state.)

As others have mentioned, there is no support for extended attributes in NFS. However, there is significant interest in it, to the extent there is a proposed standard (RFC 8276).

Drew
  • 71
  • 1
  • 3
  • 1
    While this may answer the question, [it would be preferable](http://meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Tom Aranda Dec 14 '17 at 03:04
  • 3
    I'm sorry, I don't know what you're looking for @TomAranda--I provide the link, the essential part of the answer is that there is no support for extended attributes in NFS. I also don't just have a link--the link is described as a proposed standard (the implication being that it's a proposed standard for the support of extended attributes). I even described the link with the RFC number in case the link rots, which seems _really_ unlikely in this case. Can you elaborate? – Drew Dec 15 '17 at 07:13
  • 1
    It looks like Linux 5.9 will finally support user extended attributes for NFS. Server PR: https://lkml.org/lkml/2020/8/9/137 , Client PR: https://lkml.org/lkml/2020/8/14/712 – corford Oct 05 '20 at 18:23
1

Extended attributes are not supported by nfs.There is no handler for user attributes in nfs kernel module.For more information read RFC for nfsv4.

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – AlvaroAV Feb 23 '15 at 08:39
  • which link @AlvaroAV? Can you share it? – Celik Oct 20 '15 at 10:51
  • NFS support for Extended file attributes (xattr) was added in Linux 5.9 (released 11 October 2020) – Erik Sjölund Dec 25 '20 at 14:44