Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Are there any (good known, reliable) file systems on Linux that store the creation time of files and directories in the i-node table?

If there are, is the "changed" time replaced by the creation time of an i-node in a stat call?

share|improve this question

3 Answers 3

up vote 8 down vote accepted

The ext4 file system does store the creation time. stat -c %W myfile can show it to you.

share|improve this answer
1  
Thanks. In my system stat -c %W returns 0 (creation time unknown), but that is another question... –  franziskus Feb 17 '11 at 6:30
    
But note that due to how files are handled by many programs, that creation time value may not be useful. –  mattdm Feb 17 '11 at 15:27
    
@mattdm: What do you mean? –  Legate Feb 20 '11 at 11:51
5  
@Legate: if a text editor works by copying the file to a temporary location, editing the temporary working copy, and then moving the temporary copy over the original on save, when is the creation time? –  mattdm Feb 20 '11 at 14:02

Several file systems store the file creation time, although there is no standard name for this field:

  • ufs2 → st_birthtime
  • zfs → crtime
  • ext4 → crtime
  • btrfs → otime
  • jfs → di_otime
share|improve this answer
    
To be explicit, as of 2015-03, XFS don't support (see xfs_db manpage or in XFS File System Structure –  Franklin Piat Mar 28 at 13:54

As far as I know ext4, JFS and BTRFS file systems all support an extra field in the files inode to store the creation time, though the naming might differ.

Source: LWN File Creation Times

share|improve this answer
    
// , Have you been able to verify this? AFAIK is sort of weak, for my taste, at least. –  Nathan Basanese Aug 21 at 19:24
1  
@NathanBasanese The AFAIK was reporting to JFS and BTRFS. For ext4, yes it supports it. Check debugfs command stat. Exemple: you need to thing the device where you ext4 filesystem is mounted (e.g. /dev/sda3) and you need to get a file inode number within that file system (use ls -i, let say 42000 is the number), then you simply type: debugfs -R 'stat <42000>' /dev/sda3. Run this as root, or with enough privilege. Look for the crtime field, that's the one. For JFS and BTRFS, you would need to find the equivalent debugfs command... –  Huygens Aug 21 at 22:15
    
// , NIIICE. I tried $ ls -i | grep dump.rdb 656376 dump.rdb and $ sudo debugfs -R 'stat <656376>' /dev/sda2, but I think I don't have ext4 on there, yet. If I try it on an ext4, I'll say so. –  Nathan Basanese Aug 21 at 23:10
    
@NathanBasanese You can do df -T to get the partition type or simply type mount. Make sure that the file inode belong to the correct partition. Inodes are (per their nature) specific to a partition. –  Huygens Aug 22 at 20:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.