Understand Linux inodes and file storage
In Linux, files are stored in 'blocks' (typically 4KB), but their metadata is stored in an inode (index node). The system identifies files by their inode number rather than their filename; filenames are simply human-readable aliases for these numbers.
Inode metadata includes:
- File size in bytes
- User ID and Group ID of the owner
- Read, write, and execute permissions
- Timestamps:
ctime(inode change),mtime(content change), andatime(last access) - Link count (number of filenames pointing to this inode)
- Pointers to the data blocks where the actual content is stored
Key System Behaviors:
- File Updates: Software can be updated without restarting because the system tracks the running process via the inode number. A new version can be written to a new inode under the same filename without affecting the currently executing process.
- Inode Exhaustion: A disk can run out of space even if
df -hshows available capacity if the inode table is full (common in directories with millions of tiny files). Usedf -ito check inode usage.