Полезная информация

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 1.21 Making Pathnames Chapter 1
Next: 1.23 File Access Permissions

1.22 How UNIX Keeps Track of Files: Inodes

The ability to mumble about inodes is the key to social success at a UNIX gurus' cocktail party. This may not seem attractive to you, but sooner or later you will need to know what an inode is.

Seriously, inodes are an important part of the UNIX filesystem. You don't need to worry about them most of the time, but it does help to know what they are.

An inode is a data structure on the disk that describes a file. It holds most of the important information about the file, including the on-disk address of the file's data blocks (the part of the file that you care about). Each inode has its own identifying number, called an i-number. You really don't care about where a file is physically located on a disk. You usually don't care about the i-number - unless you're trying to find the links (18.3, 17.22) to a file. But you do care about the following information, all of which is stored in a file's inode:

Each filesystem has a set number of inodes that are created when the filesystem is first created (usually when the disk is first initialized). This number is therefore the maximum number of files that the filesystem can hold. It cannot be changed without reinitializing the filesystem, which destroys all the data that the filesystem holds. It is possible, though rare, for a filesystem to run out of inodes, just like it is possible to run out of storage space - this can happen on filesystems with many, many small files.

The ls -l (22.2) command shows much of this information. The ls -i option (18.4) shows a file's i-number. The stat (21.13) command lists almost everything in an inode.

- ML

Previous: 1.21 Making Pathnames UNIX Power ToolsNext: 1.23 File Access Permissions
1.21 Making Pathnames Book Index1.23 File Access Permissions

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System