I ran du -hs
to find out how big my /home/user
directory was and it reported as 18G. I cleared out almost 4G of data and ran du -hs
again to find out how much space I actually saved and it still reports as 18G. --apparent-size
makes it report as 19G. What am I doing wrong?

- 6,396
- 2
- 42
- 56

- 153
- 4
-
Did you "clear out" the filesystem by unlinking files that were in use at the time? – David Schwartz Jun 18 '12 at 20:40
3 Answers
If the files are still in use, du
will not update.
Here's a post with an exercise so you can see this in action : (for BSD, but it's equivalent in Linux)
-
1
-
Goodness! What does this user have running to hold 4GB of files open? Wow! That's a lot of wedged zombies. (Ewww, mental image...) – lornix Jun 28 '12 at 05:11
-
@lornix: a DVD image perhaps, that was being played with VLC, mplayer etc. – Cristian Ciupitu Jun 29 '12 at 14:51
Another possibility that can cause this is filesystem compression and utilities that don't know about it. I saw this with ZFS a few years ago on Solaris but the theory should be the same for Ubuntu and any other filesystem that supports compression.
I created a file with mkfile 10g test
. After this, ls -lh
reported it as 10GB and du -h
reported it as 0.
If the 4GB you cleared out was found with ls -lh
then it might not have been taking up nearly as much space as it seemed.

- 26,337
- 7
- 59
- 90
-
1Something similar can also happen with *sparse files*. `dd if=/dev/zero of=test bs=10G seek=1 count=0` creates a file that `ls -lh` reports as having 10GBs. – Cristian Ciupitu Jun 18 '12 at 23:07
This could be caused by hard links which means that the files you deleted still exist under other names. To find them, run find -type f -links +1
.

- 6,396
- 2
- 42
- 56