Linux Commands for Extended Attributes

You can set, retrieve, restore, and remove extended attributes on files, directories, and FUSE mounted file paths using Linux commands. For more information, refer to the respective Linux man page.

To use extended attributes on files on a MapR cluster with a FUSE client mounted path, see Configuring the HPE Ezmeral Data Fabric FUSE-Based POSIX Client to enable extended attributes through FUSE client.

Set Extended Attributes

To set an extended attribute name and value on a file/directory and/or a FUSE mounted file path, run the following command:

setfattr [-h] -n name [-v value] pathname...

For example:

setfattr -n system.name -v system /mapr_fuse/testcluster/volforsnap/smallfile.txt
setfattr -n security.name -v test /mapr_fuse/testcluster/volforsnap/smallfile.txt
setfattr -n trusted.name -v trusted /mapr_fuse/testcluster/volforsnap/smallfile.txt
setfattr -n user.name -v user /mapr_fuse/testcluster/volforsnap/smallfile.txt

For more information, refer to the Linux man page.

Retrieve Extended Attributes

To retrieve extended attributes, run one of the following commands:

getfattr [-hRLP] -n name [-e en] pathname...
getfattr [-hRLP] -d [-e en] [-m pattern] pathname...

For example:

getfattr  -d -m - /mapr_fuse/testcluster/volforsnap/smallfile.txt
getfattr: Removing leading '/' from absolute path names
  file: mapr_fuse/testcluster/volforsnap/smallfile.txt
  security.name="test"
  system.name="system"
  trusted.name="trusted"
  user.name="user"

For more information, refer to the Linux man page.

Remove Extended Attributes

To remove an extended attribute by name, run the following command:

setfattr [-h] -x name pathname...

For example:

setfattr -x user.test test2

For more information, refer to the Linux man page.

Restore Extended Attributes

To restore extended attributes from a file, which must be in the format generated by the getfattr command with the --dump option, run the following command:

setfattr [-h] --restore=file...

For example:

setfattr --restore=testout
getfattr -d test2
 file: test2
 user.test="test"

For more information, refer to the Linux man page.