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

5 Answers5

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 -
derobert
  • 109,670
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 ?

X Tian
  • 10,463
  • Nice addition. Tks. – X Tian Mar 07 '17 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). – derobert Mar 07 '17 at 17:44
0

Use find command:

find /home/jenkins/jobs/ -type f -size +100M -exec ls -lh {} \;
Daniel
  • 771
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/

Murphy
  • 2,649
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