You are not logged in.

#1 2021-04-18 16:57:17

johnny.honu
Member
Registered: 2021-04-18
Posts: 18

filesystem id vs uuid

I've unsuccessfully searched for an answer, so I thought I'd ask here...

I've run across a filesystem ID using the stat -f command.  How is the filesystem ID provided by the stat -f command different than the filesystem's UUID provided in lsblk?  Does it remain static for the lifetime of the filesystem, or does it change?

Offline

#2 2021-04-18 17:16:01

tucuxi
Member
From: Switzerland
Registered: 2020-03-08
Posts: 291

Re: filesystem id vs uuid

From my limited knowledge I would say that stat reports the id of the file system and lsblk shows the id of the partition. As such, they seem unrelated.

Offline

#3 2021-04-18 19:23:30

johnny.honu
Member
Registered: 2021-04-18
Posts: 18

Re: filesystem id vs uuid

The following lsblk command will display the name each partition (name), uuid of each partition (partuuid), and, if the partition has been formatted with a filesystem, the uuid of the filesystem on the partition (uuid).  I use a handful of different filesystems: fat, ext4, xfs, and btrfs.  The uuids are all 32 hex-digits-long and are formatted with hyphens, except for the fat filesystems, which have 8 hex-digit uuids formatted with a hyphen. 

lsblk -o name,partuuid,uuid

The following stat command displays the id of the filesystem on which the file resides.  This filesystem id is only 16 hex-digits long, with no hyphens or formatting. 

stat -f <filename>

From what I can tell, there is more than one filesystem identifier.  I am writing a bash script where it would be more efficient to use the stat command to get a filesystem identifier, so long as it is static.  I hoping someone knows whether it is static or not.

Offline

#4 2021-04-18 19:45:59

loqs
Member
Registered: 2014-03-06
Posts: 19,015

Re: filesystem id vs uuid

See statfs.2

Offline

#5 2021-04-18 22:21:55

johnny.honu
Member
Registered: 2021-04-18
Posts: 18

Re: filesystem id vs uuid

THANK YOU!  It looks like it is a static filesystem identifier. From statfs.2:

The general idea is that f_fsid contains some random stuff such that the pair (f_fsid,ino) uniquely determines a file. Some operating systems use (a variation on) the device number, or the device number combined with the filesystem type.

Offline

Board footer

Powered by FluxBB