2

I have a simple linux machine running Amazon Linux AMI release 2012.09

However I am running out of space on my root mounted drive.

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1            7.9G  7.6G  212M  98% /
tmpfs                 3.7G     0  3.7G   0% /dev/shm
/dev/xvdh             100G  4.7G   96G   5% /data

The thing is /data is under / so it is counting that disk usage twice.

If I get the usage for just / it comes to 2.9G

Is there an easy way to stop this happening?

Thanks in advance.

Edit: Posted results

$ du -xcsh /
3.5G    /
3.5G    total

Seems to be right then?

5
  • df looks at partitions, not the directory structure. Even if it did, it would show 107.9 G for /. What makes you think that data is counted twice? How are you getting the usage just for /?
    – terdon
    Apr 4, 2013 at 2:35
  • I am running $ du -sh * in the /. Adding up everything I am getting the full 7.6G Used but it shows that /data is using 4.7G. Maybe I am using it wrong? But I thought that because /data is using a separate mount it shouldn't be using that? Else do you have any other suggestions?
    – Balthasar
    Apr 4, 2013 at 2:58
  • No, default du will measure /data as well. Please post the output of du -xcsh /. The x causes du to skip partitions mounted in subdirectories.
    – terdon
    Apr 4, 2013 at 3:32
  • Thanks for the response. Ok so its reading the diskspace correctly, ie without the /data directory. The main reason for even looking at this is that I have been getting disk full errors and only by clearing up space elsewhere does it come right.
    – Balthasar
    Apr 4, 2013 at 4:31
  • Does df still report 7.6G used for /? It is weird that df and du -x do not agree.
    – terdon
    Apr 4, 2013 at 10:48

1 Answer 1

1

The reason df -h and du -xcsh don't agree is that there is an open file (or multiple files) which has been deleted. The easiest way to close the file, and free up the space, is to reboot.

If you cannot reboot please refer to a blog I wrote last year addressing this very issue:

http://linuxtech.ie/wordpress/2012/10/31/missing-disk-space-linux-unix/

It goes into more detail on how to find the offending file(s).

You must log in to answer this question.

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