devutils/ATFQ/book ATFQ git

Part II · Your system

13.4 Links, inodes and "disk full"

alsoinodeinodeshard linksymlinksymbolic linklnlinksno space leftno space left on devicedisk fulldf -i

TL;DR

  • An inode is a file's record: owner, rights, size, where the data is. The name is stored in the folder, not in the inode.
  • A hard link is a second name for the same inode. A symbolic link is a small file that holds a path.
  • A filesystem can run out of inodes before space: "No space left on device" while df -h still shows room.
df -i                       # inode use per filesystem
ls -li                      # inode number of each file
ln -s /data/photos photos   # a symbolic link named photos

On your machine

alice@laptopexample
$ atfq 13.4
  nvme0n1         476.9 GiB  SSD · Samsung SSD 980 PRO 500GB
    nvme0n1p1     512.0 MiB  vfat   /boot/efi   256.0 MiB free (50%)
    nvme0n1p2     476.4 GiB  btrfs  / (+2)      120.0 GiB free (30%)
    nvme0n1p10      1.0 MiB
  sda              30.0 GiB  rotational · removable · USB DISK 3.0
    (whole disk)             exfat  /media/usb
  zram0             8.0 GiB  SSD · swap
  2 loop or empty devices not shown

An example: Alice's laptop, one of the test machines. In your terminal, this block shows your own machine, read live.

Pitfalls

Deep dive 2 questions

Why is the name not part of the file?

A folder is a list of pairs: name and inode number. That's why renaming a file within a filesystem is instant (only the folder changes), why one file can have several names, and why a file has no single "real" path.

The inode counts its names: it's the number in the second column of ls -l. When it drops to zero and nobody has the file open, the data is freed.

Why does root still have space when the disk is full?

ext4 keeps 5% of its blocks for root by default, so system services keep working when users fill the disk. That's why df shows less available space than size minus used. tune2fs -m changes the share, which can be lowered on a big data disk that holds no system files.

Commands
ln df lsof
See also
14. Disk
13.1 The hierarchy in 2 minutes