Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 am using indicator-multiload and would like it to show the Free Disk Space in my Partitions.

So, I went through the code, and found out that the author was parsing the contents of /sys/block/(device)/stat to get the read and write speeds. (where 'device' can be sda etc.).

I looked around sys/block and couldn't find anything useful that could give me info about free space in a disk. Although /sys/block/sda/size gives the total available space, I couldn't find an entry for free space.

I want to know if there is a file in the linux system which explicitly stores free space information.

If not, can you suggest a way on how I could get an indicator with stats on free disk space.

share|improve this question
up vote 3 down vote accepted

The free space isn't a property of the block device - it's a property of the filesystem on the device. Consequently, there won't be anything useful under /sys/block. Fortunately, there are other ways to query this information.

From the shell, one of the easiest ways to get the current free space is by using df:

[jk@pecola sda2]$ df -h /dev/sda[123]
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        64M  117K   64M   1% /boot/efi
/dev/sda2        20G  9.7G  9.4G  51% /
/dev/sda3        92G   65G   23G  75% /home

This uses the statfs system call to determine the free space available; if you're writing code to query free space, I'd suggest reading the statfs manpage:

man statfs

Hope this helps!

share|improve this answer
Note that obviously, df can only show info for mounted devices, since the info has to come from the filesystem. – mivk Mar 12 '13 at 23:53

You can find this information using the df command at the terminal (df -H for a more readable output).

share|improve this answer

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.