Take the 2-minute tour ×

I am trying to understand what an inode is. However, this passage from Wikipedia puzzles me:

Installation of new libraries is simple with inode filesystems. A running process can access a library file while another process replaces that file, creating a new inode, and an all new mapping will exist for the new file so that subsequent attempts to access the library get the new version. This facility eliminates the need to reboot to replace currently mapped libraries. For this reason, when updating programs, best practice is to delete the old executable first and create a new inode for the updated version, so that any processes executing the old version may proceed undisturbed.

share|improve this question

marked as duplicate by Gilles, jasonwryan, uther, rahmu, Thor Feb 14 '13 at 9:43


Take a look at these two other questions: unix.stackexchange.com/questions/4950/what-is-an-inode and unix.stackexchange.com/questions/4402/… –  Bruce Ediger Feb 13 '13 at 4:17

1 Answer 1

up vote 4 down vote accepted

In Unix-style file systems, everything the system knows about a file (except its name) is stored either in the inode or in a location pointed to by the inode. That includes its contents, ownership, modification dates, and permissions. A Unix directory entry is just a name and a pointer to the inode, and is only used when a process is opening a file. Once the file is open, the directory entry is irrelevant.

What that means is that it's possible to delete a file that's currently open without disturbing the processes that are reading or writing that file. Deleting the file simply removes the directory entry. The inode remains until all processes have closed the file, at which point the inode and all other file data are deleted (or at least marked as no longer in use and available for reclamation). This is handled by a field, called "link count", part of the inode structure.

Therefore, if you want to upgrade a shared library that's in use by a running program, you can just delete the library file. Since the program already has the file open, it won't be affected by this. Then you install the new version of the library as a new file (which gets a new inode).

share|improve this answer
And any program starting later picks up the new version, even while the processes started earlier continue using the old version. –  vonbrand Feb 13 '13 at 3:50
Two observations: some file systems (ReiserFS) don't really have "inodes", but they do store a file's metadata separate from the file's data blocks, and separate from the directory entry. Second, what metadata is kept in a location pointed to by the inode, and not in the inode itself? –  Bruce Ediger Feb 13 '13 at 4:45
@BruceEdiger, I wasn't speaking only about metadata but also the file's contents. However, extended attributes are metadata not necessarily stored in the inode. –  cjm Feb 13 '13 at 5:05
@cjm, thank you for the clear and concise answer (I like it better than the accepted answer to the tread this one duplicates). I added one sentence for clarification - feel free to edit it freely to fit your stile. –  Vorac Feb 18 '13 at 15:14
