0

I made a folder and file in it (in linux) and then I used the following command to get the Inode number of each file and directory:

ls -i -R

but when I use another computer with the same task I get different numbers for each inode, I know that it is reasonable but can everyone explain the reason of that? I mean why is the results different from computer to computer?

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
HMdeveloper
  • 2,772
  • 9
  • 45
  • 74
  • 1. Not on topic for SO. 2. You don't even know what an i-node is! – John3136 Nov 25 '13 at 22:35
  • I think Inode is taught in the topic of file implementation and so it is in the topic of Os. So I think your major is not computer science that is why you think in this way 2) Inode is a data structure used to represent a file 3) Do you think this way of answering is helpful? – HMdeveloper Nov 25 '13 at 22:44
  • I didn't answer, I commented. I'm not a student, but when I was my major was comp sci. SO is for programming problems. This is not a programming problem. – John3136 Nov 25 '13 at 23:55

1 Answers1

2

An inode (or index node) is a pointer/identifier used within the internal data-structure of a filesystem.

As such, different computers have different filesystems - talking about the data, not the type/implementation! - and thus have different inodes values for a resource. An inode is an internal identifier while the path is the external identifier.

As an analogy, imagine a C program in a modern operating system that mallocs a new object. The malloc returns a unique pointer within the process. However, many processes can share the same pointer value (when viewed as an integer address) while referring to completely unrelated objects.

user2864740
  • 60,010
  • 15
  • 145
  • 220
  • by having different file systems do you mean different file system implementation? – HMdeveloper Nov 25 '13 at 22:49
  • No. Different *data*. That is, the same filesystem type (i.e. ext4, and even on the same physical hardware), but different internal data. The system is generally able to pick *"any"* free inode value when adding a new file. Since the used (and free) inode values will vary by system (based on what previous file access has occurred) this means that the chance of two systems sharing the same inode value for a particular file (except after a *direct physical data copy*) is extremely low. – user2864740 Nov 25 '13 at 23:14
  • The *data* is the state of *all previous filesystem operations* - this includes the logical layout (which may be the same) *and* the internal filesystem data layout (which is not the same). – user2864740 Nov 25 '13 at 23:18