linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Lessons
  • How it works
  • Simulator
  • Knowledge base
  • Interview prep
Index
Categories
All entries
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
home/linux/kb/File system/inode

kb/filesystem ── File system ── beginner

Inode

An inode is a filesystem record that holds metadata and pointers to a file's data blocks. The filename lives separately, in a directory, and simply points to the inode.

view as markdownaka: inodes

What an inode is

When you create a file in Linux, the filesystem allocates an inode for it. This is a fixed structure in a reserved area of the disk, and it stores:

  • the object type (file, directory, symlink, device, and so on)
  • permissions (file-permissions): the rwx bits for u/g/o
  • the owner's UID and GID
  • the file size
  • the atime / mtime / ctime timestamps
  • the number of names that point to this inode (link count)
  • pointers to the data blocks (where the contents physically live)

The filename is just a string in a directory entry, mapped to an inode number. That is why one set of contents can have several names (hard-link), and a directory is a special type of inode holding a list of name → inode pairs.

Why it matters

A few non-obvious things follow from this:

  1. A file is not destroyed while at least one name points to it. rm removes a name from a directory and decrements the link count. When the counter reaches 0 and no process holds the file open, the data blocks are freed.

  2. Inodes are a separate pool from blocks. On ext4 their count is fixed when the filesystem is created. You can hit the inode limit while disk space is still free, the classic incident with millions of small session or cache files.

  3. mv within one filesystem is a rename (only the directory entry changes, the inode stays the same). Across different filesystems it is a copy plus a delete.

  4. A directory also uses an inode. In deeply nested projects, directories can be the third source of inode consumption after caches and logs.

§ команды

bash
ls -i ~/.bashrc

Show the inode number of a file

bash
stat ~/.bashrc

Full record: Inode, Links, Size, Access/Modify/Change times

bash
df -i

Inode usage per filesystem, the key command for diagnosing "disk full while GB are free"

bash
find / -xdev -printf '%i\n' 2>/dev/null | sort -u | wc -l

How many inodes are actually used in one filesystem (without mount points)

§ см. также

  • hard-linkHard linkHard link is a second name for the same [[inode]]. Both names are equal: the file lives as long as at least one of them exists.
  • symbolic-linkSymbolic linkA symlink is a separate shortcut file that stores a path to its target. Unlike a [[hard-link]], it has its own [[inode]], and a symlink can point at anything, including something that does not exist.
  • ext4ext4: the Linux filesystem workhorseext4 is the default filesystem on most distributions: journaling, extents, a fixed inode count set at mkfs time. The main tunes are the data mode, noatime, and lazy init. Stable for 15+ years. Does not scale like XFS.
  • sparse-filesSparse files: holes and apparent sizeA sparse file has "holes", blocks the filesystem never allocated. They read back as zeros but take no space. ls shows the apparent size, du shows the real one. Used in qcow2, backups, sparse loop.
  • file-permissionsFile permissions: rwx and chmodEvery file has three permission sets: for the owner, the group, and others. Each set is three bits: read (r), write (w), execute (x). You change them with `chmod`.

§ упоминается в уроках

  • ›beginner-02-files-and-text
  • ›beginner-03-inodes-and-links
  • ›beginner-11-find-and-grep
  • ›intermediate-08-disk-usage
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies