Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Extended File Attributes on NFS?

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...

like image 520
Celik Avatar asked Jul 08 '14 10:07

Celik


People also ask

Does NFS support extended attributes?

NFS V4 uses the existing POSIX ACLs and the extended attribute support in Linux that is supported by GPFS™.

What is extended attributes in file system?

An extended attribute is information associated with an object that provides additional details about the object. The extended attribute consists of a name, which is used to refer to it, and a value. The value can be text, binary data, or another type of data.

How are extended attributes stored?

The information in extended attributes is stored as pairs of information: a name and a value. The extended attribute's name describes what kind of information the attribute is storing while the extended attribute value holds the precise information for this file or directory.


2 Answers

The NFS code in Linux 5.9 has finally presented support for user extended attributes (user xattrs).

The NFS server updates for Linux 5.9 have support for user-extended attributes on NFS. This is the functionality outlined via IETF's RFC 8276 for handling of file-system extended attributes in NFSv4. "This feature allows extended attributes (hereinafter also referred to as xattrs) to be interrogated and manipulated using NFSv4 clients. Xattrs are provided by a file system to associate opaque metadata, not interpreted by the file system, with files and directories. Such support is present in many modern local file systems. New file attributes are provided to allow clients to query the server for xattr support, with that support consisting of new operations to get and set xattrs on file system objects."

Source: https://www.phoronix.com/scan.php?page=news_item&px=Linux-5.9-NFS-Server-User-Xattr

like image 54
GoodMirek Avatar answered Oct 14 '22 09:10

GoodMirek


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.

like image 32
fbarriga Avatar answered Oct 14 '22 08:10

fbarriga