I can find out what is wasting space with this:

 du -sm * | sort +0nr | head -30

But what if "/" is filled 100%, and there are many mountpoints, ex.: /foo, /foo2, etc. How can I get a list of directory sizes in ex.: "/" that aren't mountpoints? (recursively not mountpoints?)

UPDATE: This doesn't work:

cd /; du -sxm * 2>/dev/null | sort +0nr | head -30

since it lists directories that are mounted in ex.: "/FOO" (tried this under: AIX6.1 and SLES 9.4)


du -xm / | sort +0nr | head -30

this worked on AIX, now what? :D

  • Can you provide a list of /FOO w/ these mountings?
    – slm
    Jul 15 '13 at 8:25
  • Can you also provide a df -h?
    – ott--
    Jul 16 '13 at 9:35

If something is wasting space and you can't find it, it may be hidden beneath other mountpoints. For example of you have a /mnt/backup/ and made a backup while it wasn't mounted, the backup files will have ended up on /, but won't be visible anymore as long as /mnt/backup/ is mounted later on.

The --one-file-system switch does not help there either; you have to make a clean unobstructed mount.

mkdir /mnt/something
mount /dev/yourroot /mnt/something

Then check /mnt/something/ for files using du, xdiskusage, or whatever tools you like.

If that still doesn't yield anything, check for insane values of root reserve (for ext*, tune2fs), or check the filesystem in general (fsck) as some filesystem defects may cause used/free space to be calculated wrong.


man du itself mentions:

-x, --one-file-system
              skip directories on different file systems

so something on the lines of

du -xm * | sort +0nr | head -30

will do the trick, at least if you are using du from GNU coreutils (mine is version 8.20).

Not sure if that works with AIX (just noticed the tag after I posted the answer, sorry).

  • I updated the question with a suprise :O Jul 15 '13 at 7:13

Pass the -x option to du to avoid traversing other filesystems. Call du on the root directory itself (if you call du -x *, it traverses all filesystems whose mount point is immediately in the root directory).

du -mx / | sort -nr | head -n 30
  • Got: sort: field number is zero: invalid field specification `0nr'
    – Totty.js
    Jul 24 '14 at 19:53
  • @Totty Typo: that should have been sort -k 1nr. Or just sort -nr which is equivalent. Jul 24 '14 at 20:36
  • Ah, thanks (: I'm a noob in unix. Now it just hangs, it takes long time to show results?
    – Totty.js
    Jul 24 '14 at 21:54

If there are lots of mountpoints, or files may have been written to a mountpoint before it was mounted, it is useful to mount the device on a secondary mount point. On most systems I have worked with /mnt was available and unused. Others actually use /mnt and place mount points for removable media there. In either case you should be able to add a mount point there to mount the disk. Mount the root device there and run du against that mountpoint.

To check for files that have been deleted but are still open compare the df usage to du -k for the mountpoint. If you don't match the du blocksize the device blocksize, there will normally be differences.

Rotating log files without getting the logging program to reopen its log file can cause problems like this. Many versions of syslog will reopen their log files when sent a HUP signal, others need to be restarted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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