I need to know the creation time of a file. I tried to run the stat filename
command. But my fs does not store file creation time as metadata.
[root@s1 XYZ]# stat ./px/cd/78/cd78eholuefekgpz6c0snn5oaayypnloqxgfivszd5d.mxp
File: `./px/cd/78/cd78eholuefekgpz6c0snn5oaayypnloqxgfivszd5d.mxp'
Size: 16241 Blocks: 32 IO Block: 4096 regular file
Device: fd02h/64770d Inode: 129108489 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 509/ UNKNOWN) Gid: ( 509/ UNKNOWN)
Access: 2018-03-07 12:28:31.000000000 +0200
Modify: 2018-03-07 07:04:15.000000000 +0200
Change: 2018-03-07 12:28:31.468075157 +0200
However, I read this site and used debugfs command. It shows crtime (creation time). But the shown creation time is larger (newer) than modification time. What is wrong?
[root@s1 XYZ]# ls -i ./px/cd/78/cd78eholuefekgpz6c0snn5oaayypnloqxgfivszd5d.mxp
129108489 ./px/cd/78/cd78eholuefekgpz6c0snn5oaayypnloqxgfivszd5d.mxp
[root@s1 XYZ]# df -T ./px/cd/78/cd78eholuefekgpz6c0snn5oaayypnloqxgfivszd5d.mxp
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/datavg-datalv ext4 5986257120 5645927428 36483732 100% /data
[root@s1 fcs_backup]# debugfs -R 'stat <129108489>' /dev/mapper/datavg-datalv
debugfs 1.41.12 (17-May-2010)
Inode: 129108489 Type: regular Mode: 0644 Flags: 0x80000
Generation: 3953510053 Version: 0x00000000:00000001
User: 509 Group: 509 Size: 16241
File ACL: 0 Directory ACL: 0
Links: 1 Blockcount: 32
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x5a9fbecf:6f990a54 -- Wed Mar 7 12:28:31 2018
atime: 0x5a9fbecf:00000000 -- Wed Mar 7 12:28:31 2018
mtime: 0x5a9f72cf:00000000 -- Wed Mar 7 07:04:15 2018
crtime: 0x5a9fbecf:6f990a54 -- Wed Mar 7 12:28:31 2018
Size of extra inode fields: 28
EXTENTS:
(0-3): 516503300-516503303
Edited File is not opened. I run through the same way.
[root@s1 XYZ]# stat ./px/cd/78/cd78eholuefekgpz6c0snn5oaayypnloqxgfivszd5d.mxp
File: `./px/cd/78/cd78eholuefekgpz6c0snn5oaayypnloqxgfivszd5d.mxp'
Size: 16241 Blocks: 32 IO Block: 4096 regular file
Device: fd02h/64770d Inode: 129108489 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 509/ UNKNOWN) Gid: ( 509/ UNKNOWN)
Access: 2018-03-07 12:28:31.000000000 +0200
Modify: 2018-03-07 07:04:15.000000000 +0200
Change: 2018-03-07 12:28:31.468075157 +0200
[root@s1 XYZ]# debugfs -R 'stat <129108489>' /dev/mapper/datavg-datalv
debugfs 1.41.12 (17-May-2010)
Inode: 129108489 Type: regular Mode: 0644 Flags: 0x80000
Generation: 3953510053 Version: 0x00000000:00000001
User: 509 Group: 509 Size: 16241
File ACL: 0 Directory ACL: 0
Links: 1 Blockcount: 32
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x5a9fbecf:6f990a54 -- Wed Mar 7 12:28:31 2018
atime: 0x5a9fbecf:00000000 -- Wed Mar 7 12:28:31 2018
mtime: 0x5a9f72cf:00000000 -- Wed Mar 7 07:04:15 2018
crtime: 0x5a9fbecf:6f990a54 -- Wed Mar 7 12:28:31 2018
Size of extra inode fields: 28
EXTENTS:
(0-3): 516503300-516503303
[root@s1 XYZ]# lsof ./px/cd/78/cd78eholuefekgpz6c0snn5oaayypnloqxgfivszd5d.mxp
[root@s1 XYZ]#
my fs does not stores file creation time as metadata.
. If that's true then you cannot get the creation time no-matter what you do. Anything you do which gives a creation time will be meaningless.crtime
: see the wiki on kernel.org and theinode.c
source. It's stored at offset 0x90 of the inode. See @Stéphane Chazelas's comment.