Super User is a question and answer site for computer enthusiasts and power users. 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

By default, Linux reserves some fraction of a filesystem for the root user, at least on ext4 (to prevent ordinary users from filling the drive completely and crashing the system, and to reduce fragmentation). However, df only displays the free space apparent to regular users (even when run as root). How do you display the "real" free space, that would be accessible to root?

share|improve this question
up vote 7 down vote accepted

I am not sure there is a tool built in, but assuming you have left the reserved at the default 5% then this will tell you:

df / | grep dev | cut -f 3,6 -d\  | awk '{print ($1*.05)+$2}'

df the root, grep for the line with dev in it (to remove the header), cut the size and available fields, then use an awk script to calculate 5% of the disk size added to the available.

You could pull the actual reservation from tune2fs -l <device> and combine this with the above in a script.

share|improve this answer
Right, so the following command will tell us how much of the partition space is reserved for privilegied users: tune2fs -l /dev/DEVICE | egrep "Block count|Reserved block count". E.g. for my "multimedia buffer" partition : Block count: 2621440 and Reserved block count: 128449 : 4.9% of the available blocks (conservative setting to help prevent fragmentation). – lliseil Jul 9 at 13:18

By using the command tune2fs (found in /sbin/tune2fs), you can easily determine the reserved space: (and more!)

tune2fs -l /dev/sda1

I'll provide my system's info for reference, I'm going to remove extraneous lines not important to this question:

The header... and volume name, I label all my drives, makes them easy to identify if needed.

tune2fs 1.42.4 (12-Jun-2012)
Filesystem volume name:   xenon
Last mounted on:          /

REALLY want this to say "clean" while the system is running. Honest!

Filesystem state:         clean

This is where the data storage capacity information begins:

Here you can see that I have 121,179,648 blocks total... with a block size of 4K (4096), that multiplies out to some big number (462-ish GB). (Block size is noted below)

Block count:              121179648

And the reserved blocks... by looking at the number above, and the number below.. you should be able to relatively quickly figure out I have 1% reserved. In this case (4.62-ish GB)

Reserved block count:     1211796

How much free space currently available? Right here!

Free blocks:              104090586

And the all important block size. Useful for multiplying.

Block size:               4096

These lines say WHO the blocks are reserved for... user 0, root, in this case

Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)

There's lots more information available here, but this should give you an ability to quickly ascertain how much is available, and how much more is reserved for root. Simple math.

Hope this helps. pages are your friends.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .