2

I'm trying to find out what folders occupy / partition. I see that lots of disk space goes to jenkins directory

sudo du -sh /home/jenkins
289G /home/jenkins

When I examine jenkins directory folder I get the largest folder is:

sudo du -sh /home/jenkins/*
137G /home/jenkins/jobs

And rest of the folders are relatively small, tens of K/M... In total there are 50 folders under /home/jenkins.

How can I find who "eats" the space?

Thanks

Gilles 'SO- stop being evil'
864k204 gold badges1.8k silver badges2.3k bronze badges
asked Mar 7, 2017 at 17:08
4
  • 1
    Make sure the du command is also looking at hidden files. Commented Mar 7, 2017 at 17:09
  • Not really sure what you mean by "eats". Are you trying to find the largest files within /home/jenkins/jobs? You also mentioned partitions, are you trying to find out what partitions they live on? Commented Mar 7, 2017 at 17:17
  • see also: unix.stackexchange.com/questions/48059/… Commented Mar 7, 2017 at 19:11
  • Thanks for your help. Indeed it was a hidden maven local repository .m2. Commented Mar 8, 2017 at 8:40

5 Answers 5

6

The difference between: sudo du -sh /home/jenkins and sudo du -sh /home/jenkins/* is that in almost all shells (with the default setttings), * does not include hidden files or directories. Hidden means names starting with a period (e.g., if there is a /home/jenkins/.temp/, that would not be included in the second du).

So it'd appear you have about 289-137=152 GiB of hidden files. The easiest way to find out where they are is something like this:

sudo du -m /home/jenkins | sort -nr | less

Taking off the -s will make du show you the subdirectories everything is in, which sounds like what you want. That'll include hidden ones. If that still doesn't find it, add an -a:

sudo du -am /home/jenkins | sort -nr | less

that will additionally show individual files, in case you have a few very large hidden files. It will probably also take a bit longer to run (adding files often greatly expands the output).

There are also graphical frontends you can use; personally, I use xdiskusage (but maybe just because I've been using it forever):

sudo du -am /home/jenkins | xdiskusage -
answered Mar 7, 2017 at 17:43
0

Look inside jobs with following command

du -sm /home/jenkins/jobs/* |sort -nr

I have suggested a reverse sort so largest are last, just above your new command line, -n specifies a numeric comparison, du output is set to always show as MB so that lines can be sorted sensibly.

edit: someone suggested also adding -a to du to count all files (including hidden) but comment has disappeared ?

answered Mar 7, 2017 at 17:21
2
  • Nice addition. Tks. Commented Mar 7, 2017 at 17:38
  • Sorry for the confusion—that was my comment, but then I realized I had a lot more suggestions than would fit in a comment so added my own answer (and deleted my comment). Commented Mar 7, 2017 at 17:44
0

Use find command:

find /home/jenkins/jobs/ -type f -size +100M -exec ls -lh {} \;
answered Mar 7, 2017 at 17:48
1
  • hopefully they don't have hundreds of 99Mb files! Commented Mar 7, 2017 at 19:09
0

For a quick, graphical overview you can use Filelight, which makes it easy to follow the paths with the largest share of disk usage, or a similar utility:

http://www.makeuseof.com/tag/how-to-analyze-your-disk-usage-pattern-in-linux/

answered Mar 7, 2017 at 17:57
0

Maybe these three options together can achieve the results that you're expecting:

-s, --summarize

display only a total for each argument

-c, --total

produce a grand total

-h, --human-readable

print sizes in human readable format (e.g., 1K 234M 2G)

linus@host: / $ sudo du -sch *
9,8M bin
362M boot
4,0K cdrom
12K dev
32K docker
170M etc
9,5G data
36G home
0 initrd.img
0 initrd.img.old
2,9G lib
4,4M lib64
16K lost+found
84G media
12K mnt
1,1G opt
du: cannot access ‘proc/6836/task/6836/fd/4’: No such file or directory
du: cannot access ‘proc/6836/task/6836/fdinfo/4’: No such file or directory
du: cannot access ‘proc/6836/fd/4’: No such file or directory
du: cannot access ‘proc/6836/fdinfo/4’: No such file or directory
0 proc
19M root
du: cannot access ‘run/user/1000/gvfs’: Permission denied
1,7M run
13M sbin
4,0K srv
0 sys
52K tmp
7,5G usr
14G var
0 vmlinuz
0 vmlinuz.old
154G total 
answered Mar 7, 2017 at 18:21

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.