Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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)

UPDATE:

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

this worked on AIX, now what? :D

share|improve this question
    
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
add comment

4 Answers

up vote 1 down vote accepted

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).

share|improve this answer
    
I updated the question with a suprise :O –  gasko peter Jul 15 '13 at 7:13
add comment

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.

share|improve this answer
add comment

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 -k 0nr | head -n 30
share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

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.