lsattr -v gives me the "version number" of given file(s).

What does this mean?

On Redhat 7.3, I could've sworn all the version numbers were 1 except those I changed with chattr -v.

On Fedora 11, they appeared to be random numbers.

Setting version numbers or even having multiple versions of a file could be very useful, so I want to understand how "versioning" works in ext3.

2 Answers 2


lsattr -v invokes the EXT2_IOC_GETVERSION ioctl for the file. This, in turn, retrieves the inode's i_generation field. This is a feature primarily intended for use with NFS: each time an inode gets allocated, one has to make sure it gets a new generation. Otherwise, NFS clients with stale file handles may manage to access data that weren't meant for them. ext2/ext3/ext4 allocates the generation number from a volume-global counter s_next_generation, which is incremented on every allocation.


This is not really an answer, but just a interresting find.

I played around with lsattr -v and it seems like each new file you create gets a unique number assigned to it. Im not sure if this is correct, my expirement is documented below.

$ mkdir temp                  # make a new folder
$ cd temp       
$ touch a b c d e f g         # create a lot files in that folder.
$ lsattr -v *                 # checkout those files using lsattr -v
1386486996 -------------e- a
1386486997 -------------e- b
1386486998 -------------e- c
1386486999 -------------e- d
1386487000 -------------e- e
1386487001 -------------e- f
1386487002 -------------e- g

This behaviour could be limited to the distribution or the disk format.

  • So it's sort of like an inode number, but it never repeats for the life of the filesystem?
    – user2267
    Oct 30, 2010 at 20:52
  • OK, I used "chattr -v 1 file*" to change several files' version number. It worked (lsattr showed version 1) and the files didn't get merged into each other or anything weird. So I think this is still an open question. Is it just "we had extra space for an int in the inode", or does it have a meaning/usage/history/etc (other than NFS above)
    – user2267
    Nov 2, 2010 at 20:23
  • 1
    add this to your question, by editing your question. That way more people get to see it...
    – Stefan
    Nov 2, 2010 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy