Understanding the “Birth” Field in stat Command Output: File Creation Time in Linux/Ext4 Filesystems


2 views

While examining file metadata using stat on Fedora 16 with ext4 filesystem, you might have noticed a curious field called "Birth". This represents the file creation timestamp, a feature that wasn't always available in Linux filesystems.

# Example stat output showing Birth field
stat myfile.txt
  File: 'myfile.txt'
  Size: 1024       Blocks: 8          IO Block: 4096   regular file
  ...
  Birth: 2023-05-15 14:30:22.000000000 +0000

Not all filesystems support birth time (also called crtime). Here's the current support status:

  • ext4: Supported since Linux 3.0 (requires kernel 2.6.38+ with ext4)
  • btrfs: Supported
  • xfs: Supported since Linux 4.9
  • ext3/ext2: Not supported

You can access the birth time through various methods:

# Using stat command
stat --format '%W' file.txt  # seconds since epoch
stat --format '%w' file.txt  # human-readable format

# Programmatic access in C:
struct statx {
    ...
    struct statx_timestamp stx_btime; /* File creation time */
    ...
};

File creation time can be useful for:

  1. Forensic analysis of file systems
  2. Tracking when configuration files were created
  3. Monitoring when temporary files first appeared
  4. Version control systems that need precise creation time

If you see Birth: - in stat output:

# Verify filesystem type
df -T /path/to/file

# Check kernel version (needs >= 2.6.38)
uname -r

# Verify filesystem features (for ext4)
tune2fs -l /dev/sdX | grep features

Remember that even on supported filesystems, birth time might not be available for files created before the feature was enabled.


While examining file metadata on my Fedora 16 system with ext4 filesystem, I noticed an intriguing field called "Birth" in the output of the stat command. This appears to be a relatively new addition that isn't widely documented.

# stat example.txt
  File: 'example.txt'
  ...
  Birth: -

The "Birth" field represents the original creation time of a file, distinct from:

  • Access time (atime)
  • Modification time (mtime)
  • Change time (ctime)

This feature became available when Linux kernel developers implemented file creation time (crtime) support in ext4. The functionality was added around kernel version 2.6.38.

In ext4 filesystems:

  • The birth time is stored in the inode's i_crtime field
  • Occupies 8 bytes in the inode structure
  • Persists even if the file is moved within the same filesystem

To display birth time in different formats:

# Human-readable format
stat -c '%w' filename

# Seconds since epoch
stat -c '%W' filename

# Full birth time details
stat -c 'Birth: %w' filename

Several conditions affect birth time visibility:

  • Only supported on certain filesystems (ext4, btrfs, zfs)
  • Requires kernel support (Linux 2.6.38+)
  • Files created before enabling the feature won't have this metadata

To verify if your filesystem supports birth time:

# Check filesystem type
df -Th

# Test with a newly created file
touch testfile
stat testfile | grep Birth

For developers, this metadata can be useful for:

# Python example
import os
from datetime import datetime

stat_info = os.stat('file.txt')
birth_time = stat_info.st_birthtime
print(datetime.fromtimestamp(birth_time))

Note that not all Python versions may support st_birthtime - you may need to use platform-specific solutions.

If you see Birth: - in the output:

  • The filesystem doesn't support creation timestamps
  • The file was created before enabling the feature
  • The stat implementation is outdated

For systems where this information is critical, consider:

# Alternative tracking method
touch -t 202201010000 /path/to/timestamp_file