Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where are extended attributes stored?

This is a simple question but I've done some research and can't find any answers... So does anyone know if when we define extended attributes through xattr, those attributes are stored within - as a part of - the file'contents(in the biggining, in the end?), or if the inode has a special region to store these?

And by the way, i've read that in ext4 "each extended attribute is limited to a filesystem block (e.g. 4 KiB)". I can't tell if this is enough if I wanted to store 7 extended attributes to each file in the file system. Is this reallistic?

My last question is if those extended attributes are portable in the sense that if the files move to other machines with different file systems what happens to this attributes?

like image 920
user2900870 Avatar asked Dec 16 '13 18:12

user2900870


People also ask

How are extended attributes stored?

Extended attributes are arbitrary metadata stored with a file, but separate from the file system attributes (such as modification time or file size). The metadata is often a null-terminated UTF-8 string, but can also be arbitrary binary data.”

Where are file attributes stored?

File attributes are metadata values stored by the file system on disk and are used by the system and are available to developers via various file I/O APIs.

What is extended attributes in file system?

Extended file attributes are file system features that enable users to associate computer files with metadata not interpreted by the filesystem, whereas regular attributes have a purpose strictly defined by the filesystem (such as permissions or records of creation and modification times).

Where are Xattrs stored?

Extended attributes (xattrs) are typically stored in a separate data block on the disk and referenced from inodes via ``inode.


1 Answers

If you look at the inode spec, you'll discover that there is a small amount of space at the end of the inode to accommodate extended attributes. If you overflow that area, ext4 allows to you allocate another block (basically like a resource fork) for additional extended attributes. That 4KB restriction is per attribute, per file, so you can certainly store 7 extended attributes per file, unless the attribute is a BLOB larger than 4KB. However, if you overrun the space at the end of the inode, you'll be allocating blocks to metadata instead of data, reducing the usable size of your file system.

Source: https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout#Extended_Attributes

To answer your question about portability, extended attributes are not copied by default, even within a single file system, and are not portable between file systems.

See: https://unix.stackexchange.com/questions/44253/how-to-clone-copy-all-file-directory-attributes-onto-different-file-directory for some further discussion on this. Rysnc can do a lot for copying extended attributes, but if the target file system doesn't support xattrs, you're out of luck.

like image 127
aleatha Avatar answered Oct 04 '22 11:10

aleatha