Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I ran df, and the output appears almost instantly:

(FS        Size  Used   Avail  Use%)
/dev/sda1  145G  8.4G   130G   7%

sda1 is an ext4 partition.

Without summing the size of all files, how can df give me the space information almost instantly?

share|improve this question
up vote 3 down vote accepted

Like traditional Unix File Systems, ext2, ext3 and ext4 have a segment of metadata called a superblock, which contains information about the configuration of the file system. The primary superblock is stored at a fixed offset from the start of the partition, and since the information it contains is so important, backup copies of the superblock are stored throughout the file system.

The information the superblock contains includes the total number of inodes and blocks in the filesystem and how many are free. This information can be used to calculate the used and available space of the file system efficiently.

share|improve this answer
+1 You're right, the superblock is important, so much so that a copy is almost always kept in memory such that df doesn't even have to go to disk to get the allocation totals. – msw Sep 27 '13 at 12:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.