question regarding fsid

Abhishek Rai abba at
Mon Nov 10 11:19:04 PST 2003

i was trying to understand the nfs server code in freebsd-5.1 when i
stumbled into something strange. These are the filesystem ids that were
revealed by both statfs and dumps of the nfs traffic.

fs: /
fsid[0] = 3f607f14
fsid[1] = 1c47f86e

fs: /tmp
fsid[0] = 3f607f14
fsid[1] = 1b067190

fs: /usr
fsid[0] = 3f607f14
fsid[1] = 6f1b0cb8

fs: /var
fsid[0] = 3f607f14
fsid[1] = c591f34d

All these have identical first four bytes. but differ arbitrarily in the
other 4. So, I looked up file system mounting code in the freebsd5.1
kernel to look for where do fsids come from.
During a disk-based filesystem mounting, the kernel starts by getting the
fsid from the disk. However if the fsid value is
trivial(zero) or there is already a mounted-fs with the same fsid value,
then vfs_getnewfsid() allocates a new fsid. however there are reasons
which tell me that at least in the case i've presented above, the fsid is
NOT coming from vfs_getnewfsid() => it IS coming from the disk.

I looked into the mkfs/newfs code but didn't find anything that sets the
fsid on the disk at the time of fs creation. So who and when puts the fsid
field on the disk ? And how is this fsid value chosen ?

thanks a lot!

More information about the freebsd-fs mailing list