2

I am trying to understand the concept of the inode number of an inode.

Is an inode number an/the id of an inode?

Does an inode have exactly one inode number? or can an inode have zero or more than one inode numbers?

When is an/the inode number assigned to an inode?

Is the inode number of an inode changeable? Does it make sense to change the inode number of an inode?

If I need to be specific, I am referring to file systems native to Linux.

2

The inode number is simply the unique identifier of an inode. It is analogous to a UID or GID. Thus, each inode has exactly one identifier.

To find the inode number of a file, use either ls -i or stat.

Each directory in Unix is just a list of (filename, inode number) pairs. The inode number serves as a "pointer" to find the inode structure itself. The inode in turn records the location of the actual file contents.

An inode number is assigned to an inode when it is created, which is whenever a new file is created.

Edit to address the points below:

  1. This is actually a tricky question. I strongly suspected the answer would be "no", but I wasn't 100% certain so I did some quick research. I found a few sources saying that the inode number can in fact change if a file is moved, although I could not reproduce this behavior locally, so it seems this depends on some external factors. See here for example. Note that the inode number can certainly not change from a move if it has multiple hardlinks, or the hardlinks would break.

  2. Yes. Otherwise it would be possible for the operating system to run out of inode numbers, which would be very bad. This is exactly the same reason process IDs can eventually be reused by the OS.

  3. I addressed this above. Each inode has exactly one inode number.

  • Thanks. 1. can the inode number of a inode change? 2. When an inode is deleted, can its inode number be reused? 3. Does an inode have exactly one inode number? or can an inode have zero or more than one inode numbers? – Tim Jan 16 '16 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.