Wednesday, June 22, 2005

Extended File System Attributes

Clean forgot there were something called extended attributes. This jogged my memory a bit. In summary: For ext3 or xfs, add the user_xattr option while mounting. Eg. in /etc/fstab edit the lines that mount ext3 or xfs file systems like this:
/dev/hda1 / ext3 defaults,noatime,user_xattr 0 1 Then remount the partitions:
mount -o remount,user_xattr / Then use setfattr and getfattr to set/get extended attributes.
  • Create an attribute 'testing' in the 'user' namespace: setfattr -n user.testing -v "this is a test" test-1.txt
  • Delete the attribute: setfattr -x user.testing test-1.txt
  • Retrieve the attribute: getfattr -n user.testing test-1.txt
  • Backup all extended attributes: getfattr --dump * > data_file
  • Restore all extended attributes: setfattr --restore=data_file
And oh, if you dont have setfattr and getfattr, you can get the sources from the SGI site or look for 'attr' on rpmseek or rpmfind.net

No comments: