Billy The Bob
Billy The Bob

Reputation: 331

Inode Number is changing

I'm having a problem with inode number. When I mount one usb disk (let's say usb-a) and then mount another usb disk (usb-b) the inode number in usb-a is changed.

Is this normal? what may cause this issue? I'm using Linux Kernel 2.6. usb-a is vfat and usb-b is ntfs.

Thanks in advance guys.

Upvotes: 4

Views: 1810

Answers (1)

davidg
davidg

Reputation: 6027

FAT (and similarly VFAT) file systems don't actually store inode numbers on disk. Instead, Linux invents inode numbers on-the-fly for files as they are seen. These generated inode numbers are stored in a cache to try and keep them consistent, but this cache has a fixed size; once it is full, older entries are thrown away.

Presumably the act of mounting your second filesystem is sufficient to cause the inode number cache on the VFAT filesystem to forget about your files, causing new inode numbers to be allocated, and presenting the problem you observe.

More information:

  • Discussion about a bug related to this problem on the findutils mailing list
  • Linux kernel sources: fs/fat/inode.c (in particular, the call to iunique in fat_build_inode which performs the inode number allocation).

Upvotes: 6

Related Questions