Stat command differences on platforms

This isn’t a problem ‘per se’ - just something I noticed today…

I use the “stat /” command to get the install date for my Linux OS, works out of the box on

  • Red Hat (8) x86_64
  • Ubuntu 22.04 (x86_64)
  • Ubuntu 22.04 arm64/aarch64 on a Pi 4 (8 GB model).

But - it doesn’t work on

  • Ubuntu 16.04 on Orange Pi 2E+(via Armbian - yeah I know it’s EOL, but all it does is run transmission-daemon, and I won’t do anything with it until it breaks)
  • Raspbian Stretch on RPi3B
    (they both have a “Birth” field, but it’s unpopulated)

It “sorta/kinda” works on :

  • MacOS
  • FreeBSD (via FreeNAS)
    i.e. it doesn’t have “Birth” field at the end, but, I can kinda glean from the output (MacOS and FreeBSD are, unsuprisingly, very similar) what day that “/” was first created…

Hmmm - just booted up an REL7 VM - and it too has an empty “Birth” field.

I don’t think its a kernel thing anyway? But why have it there, if it’s not going to be used? REL 7 is on kernel 3, REL 8 is on kernel 4, the other two that have “Birth” populated (Ubuntu 22.04 on x86_64 and arm64) are Kernel 5, but the Pi3 is running Kernel 4…

REL 7 :

[x@rel7 ~]$ uname -a
Linux rel7 3.10.0-1160.el7.x86_64 #1 SMP Tue Aug 18 14:50:17 EDT 2020 x86_64 x86_64 x86_64 GNU/Linux
[x@rel7 ~]$ sudo stat /
  File: ‘/’
  Size: 224       	Blocks: 0          IO Block: 4096   directory
Device: fd00h/64768d	Inode: 64          Links: 17
Access: (0555/dr-xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:object_r:root_t:s0
Access: 2022-07-25 13:19:12.575000000 +0800
Modify: 2022-06-21 10:24:19.744000000 +0800
Change: 2022-06-21 10:24:19.744000000 +0800
 Birth: -

REL 8 :

╭─x@fuglpige ~  
╰─➤  uname -a
Linux fuglpige 4.18.0-372.9.1.el8.x86_64 #1 SMP Fri Apr 15 22:12:19 EDT 2022 x86_64 x86_64 x86_64 GNU/Linux
╭─x@fuglpige ~  
╰─➤  sudo stat /
  File: /
  Size: 224       	Blocks: 0          IO Block: 4096   directory
Device: fd00h/64768d	Inode: 128         Links: 17
Access: (0555/dr-xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:object_r:root_t:s0
Access: 2022-04-12 17:45:41.679323287 +0800
Modify: 2022-04-01 13:45:59.972594135 +0800
Change: 2022-04-01 13:45:59.972594135 +0800
 Birth: 2022-04-01 13:20:21.929182000 +0800

Debian Stretch (armhf/arm7l) on Pi3B

╭─x@telesto ~  
╰─➤  uname -a
Linux telesto 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux
╭─x@telesto ~  
╰─➤  sudo stat /
  File: /
  Size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: b302h/45826d	Inode: 2           Links: 21
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-07-14 01:16:47.761892113 +0800
Modify: 2019-04-08 18:25:39.399999997 +0800
Change: 2019-04-08 18:25:39.399999997 +0800
 Birth: -

Was starting to think it might be something to do with “media” - the Pi3 and the OrangePi aren’t booting off a “hdd” in that sense, the Pi3 booting off SD-Card, the OrangePi on 16 GB onboard EMMC…

But the red herring is the REL 7 system… sure it aint exactly a “physical” HDD or SSD, but it is presented to REL 7 as one via VirtualBox…

Hmmm… Curious…
– just noticed - I installed that REL8 base system on April Fool’s Day! :smiley: More fool me!

Are these different stat versions?

In some systems, stat is a builtin shell command, in others it is a separate utility. So it may not always be the same program.

The other issue is stat is about properties of a filesystem. If they arent all ext4, they may keep different properties. Do you know where filesystems store this info? … or it it generated on the fly?

Except for the Red Hat machine(s) - everything has root “/” on ext4 (except off course macOS and FreeBSD - mac = HPFS or whatever they’re calling it these days [apfs ?], and FreeBSD is on ZFS). Red Hat uses xfs… that’s the only difference as far as filesystems go across Linux…

1 Like

@daniel.m.tripp
In my Debian 11 (x86_64)

nevj@mary:/etc/grub.d$ stat /
  File: /
  Size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: 804h/2052d	Inode: 2           Links: 21
Access: (0755/drwxr-xr-x)  Uid: (   99/ UNKNOWN)   Gid: (   99/ UNKNOWN)
Access: 2022-07-04 18:18:25.079689798 +1000
Modify: 2022-04-18 19:47:46.213785259 +1000
Change: 2022-06-27 17:08:07.179358439 +1000
 Birth: 2021-01-09 08:17:13.000000000 +1100
nevj@mary:/etc/grub.d$ stat --version
stat (GNU coreutils) 8.32
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Different to your Debian stretch

My Void (x86_64) is the same as above, same version 8.32 and the birth date is present