0

I am curious how and where Linux (and any operating system that make use of Inode for its file system) keep track of free inodes that can be used? When a new file is crated, which inode does the operating system assign it to? Things get more complex as files are continuously created and deleted. How in general an OS manage which inodes are free and which are used?

I would guess the inodes are structured like a free list, similar to a memory allocator. But when look at all descriptions on the inode structure I did not find a filed of pointer for "next available inode". I think this is some important issue but, curiously, I am not able to find one literature with a definite answer.

J. Li
  • 1

2 Answers2

1

First off, let's divorce the notion of inodes from Linux; inodes are a feature of the ext3, ext4, and UFS file systems as opposed to an OS. So where is inode information stored? The following link should answer that.

https://serverfault.com/questions/212766/where-is-the-inode-number-stored?newreg=ddf0ea8fd887447698c8f95

Regarding "free" inodes, inodes are not created until a new file or directory is created; there are no such thing as "free" inodes.

Community
  • 1
  • 1
1

Where inodes are exactly stored is file system dependent, just like whether inodes are relevant or not.

Most traditional Unix/Linux file systems (e.g. ufs, ext2, ext3, ext4, gfs2, ocfs2, ...) do create a fixed size inode table stored on disk. This table is cached in RAM.

Exceptions are reiserfs, jfs, xfs, btrfs and zfs, which are able to dynamically allocate new inodes.

With the latter ones, free inodes doesn't make a lot of sense but with the former ones, one can definitely run out of inodes if the sizing done at file system creation time wasn't appropriate. In addition to the full inode table, there is usually also a free inode list stored in the file system.

NTFS has something similar to inodes uner the cover and finally, some file systems do not use inodes at all, like fat32 and iso9660.

jlliagre
  • 29,783
  • 6
  • 61
  • 72