I have written a code to analyze the file system statistics (say io,total no if files etc.) for RHEL. Now user delete the filesystem and create a new filesystem but with the same name.
Now my code is not able to differentiate between the file system and display data about FS which confuses user like which belongs to new and which belogs to old FS.
As my code is reading file system by its name. So if i get a unique id for the file system assigned by OS, it will help.
I expect OS will assign unique id every time file system create.
Can someone help me to fix this?
You can inspect the UUID of the filesystem, which should be unique for each filesystem.
Have a look at:
If
/dev/disk/by-uuiddoes not exist by default (e.g. on RHEL4), you can still query the UUID usingtune2fsorblkid. For example:or
P.S. If you need to do a reverse mapping (find device based that has a specific UUID), you can use
findfs UUID=<the-uuid>