Skip to main content
Engineering LibreTexts

04-A.3: Inodes

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Linux Inodes

    A file system relies on data structures about the files, as opposed to the contents of that file. The former are called metadata—data that describes data. Each file is associated with an inode, which is identified by an integer, often referred to as an i-number or inode number.

    As files are opened for reading and writing they are assigned numerical file descriptors by the operating system. These file descriptors then point to a file table keeping track of the mode of the file - write, read, or read and write. Then the file table points to the inode table which then points to the specific physical file.
    Figure \(\PageIndex{1}\): File descriptors for a single process, file table and inode table ("File_table_and_inode_table.svg" by QwertyusWikimedia is licensed under CC BY-SA 4.0)

    Inodes store information about files and directories (folders). Each and every file under Linux (and UNIX) has the following attributes:

    • File type (executable, block special etc)
    • Permissions (read, write etc)
    • Owner
    • Group
    • File Size
    • File access, change and modification time (Remember UNIX or Linux never stores file creation time - this is a favorite question asked in UNIX/Linux sys admin job interviews.)
    • File deletion time
    • Number of links (soft/hard)
    • Extended attribute such as append only or no one can delete file including root user (immutability)
    • Access Control List (ACLs)

    On many types of file system implementations, the maximum number of inodes is fixed at file system creation, limiting the maximum number of files the file system can hold. A typical allocation heuristic for inodes in a file system is one inode for every 2K bytes contained in the filesystem.

    The inode number indexes a table of inodes in a known location on the device. From the inode number, the kernel's file system driver can access the inode contents, including the location of the file, thereby allowing access to the file. A file's inode number can be found using the ls -i command. The ls -i command prints the i-node number in the first column of the report.

    File names and directory implications:

    • Inodes do not contain its hardlink names, only other file metadata.
    • Linux directories are lists of association structures, each of which contains one filename and one inode number.
    • The file system driver must search a directory looking for a particular filename and then convert the filename to the correct corresponding inode number.

    Adapted from:
    "inode" by Multiple ContributorsWikipedia is licensed under CC BY-SA 3.0

    04-A.3: Inodes is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?