Joe
Joe

Reputation: 401

Differentiate between different filesystem with the same name

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?

Upvotes: 0

Views: 287

Answers (2)

Shawn Chin
Shawn Chin

Reputation: 86854

You can inspect the UUID of the filesystem, which should be unique for each filesystem.

Have a look at:

[root@server]# ls -l /dev/disk/by-uuid/

If /dev/disk/by-uuid does not exist by default (e.g. on RHEL4), you can still query the UUID using tune2fs or blkid. For example:

[root@server]# tune2fs -l /dev/sda1 | awk '/Filesystem UUID/{print $3}'

or

[root@server]# blkid /dev/sda1 | awk '{print $3}'

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>

Upvotes: 1

Max DeLiso
Max DeLiso

Reputation: 1244

Your best bet would probably be to store other identifying information about the filesystem besides it's name, for instance it's metadata, type, uuid of the partition it's on, etc...

Upvotes: 1

Related Questions