14.2. How Unix Keeps Track of Files: InodesThe 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 (Section 9.24, Section 10.3) 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 as it is possible to run out of storage space -- this can happen on filesystems with many, many small files. The ls -l (Section 50.2) command shows much of this information. The ls -i option (Section 10.4) shows a file's i-number. The stat command lists almost everything in an inode. -- ML Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|