0

From man chattr

When a file with the 'A' attribute set is accessed, its atime record is not modified. This avoids a certain amount of disk I/O for laptop systems.

However when I am remounting a filesystem with the noatime mount option:

[root@localhost ~]# mount -o remount,noatime /dev/sdb1 /newfs/

creating a file in it

[root@localhost ~]# cd /newfs/
[root@localhost newfs]# touch myfile

and getting its file attributes:

[root@localhost newfs]# lsattr myfile 
-------------e-- myfile

the A file attribute is not set despite the fact.

Is this the expected behavior?

pkaramol
  • 2,587
  • 4
  • 36
  • 71
  • `lsattr(1)` does not list the [extended attributes](http://man7.org/linux/man-pages/man7/xattr.7.html) and `chattr(1)` does not change them. Both commands are working with the *file attributes* which are extra inode flags supported by some filesystems with like ext4, btrfs or xfs. The two are completely unrelated and independent. Extended attributes are notably used to implement file capabilities(7), selinux (`security.selinux`) and ACLs (`system.posix_acl_access`). –  Apr 23 '19 at 13:00

2 Answers2

3

Yes, this is expected: the two behaviours are orthogonal. Setting the A attribute on a file ensures that its access time is never updated, irrespective of mount options. Mounting a file system with noatime ensures that no access time is updated on it, irrespective of file attributes.

Mounting a file system with a given set of options doesn’t affect any related attributes on files created while the options are active; thus files created with noatime active don’t have the A attribute automatically set, just like it’s possible to create device nodes on a file system mounted with nodev, or executables on a file system mounted with noexec.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
1

It is the expected behaviour.

Either of them will prevent the atime being updated, but they are independent.

The kernel has no system call to query the overall status. You have to check both of them yourself.

sourcejedi
  • 48,311
  • 17
  • 143
  • 296