ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    What Is Eating CentOS Disk Space

    IT Discussion
    centos linux storage du df
    2
    34
    8.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by

      Let's start by determining which filesystem is the culprit. We can track this down with:

      df -h

      Let us know the output of that command.

      1 Reply Last reply Reply Quote 0
      • scottalanmillerS
        scottalanmiller
        last edited by

        Once we know where the issue is, we can use the "du" command to dig into it. If we determine that the space is being used up on / (the root partition) then we can dig into that with this:

        *du -shx / **

        1 Reply Last reply Reply Quote 0
        • scottalanmillerS
          scottalanmiller
          last edited by

          But if that returns a lot of data, that can be annoying, so a way to make that show up in order is like this:

          du -smx * | sort -n

          This will sort the output putting the biggest space users at the bottom of the list (so that the stuff that scrolls off the top is the little stuff that you don't care about.

          1 Reply Last reply Reply Quote 0
          • scottalanmillerS
            scottalanmiller
            last edited by

            So the process to track down the biggest problems are to start with df -h to determine which filesystem is the problem. Then start at the root of that filesystem and use du -smx * | sort -n to find the biggest space using directories there. Then cd into the directories and run du -smx * | sort -n again and keep looping through it like this until you find where space is being used that should not be.

            1 Reply Last reply Reply Quote 0
            • ajin.cA
              ajin.c
              last edited by scottalanmiller

              df -h

              Filesystem            Size  Used Avail Use% Mounted on
              /dev/mapper/vg_trvbackup-lv_root
                                     50G   48G     0 100% /
              tmpfs                 3.9G     0  3.9G   0% /dev/shm
              /dev/sda1             485M   53M  407M  12% /boot
              /dev/mapper/vg_trvbackup-lv_home
                                    402G  145G  236G  39% /home
              /usr/tmpDSK           1.6G   37M  1.5G   3% /tmp
              /dev/sdb1             1.5T  286G  1.2T  20% /backup/current
              /dev/sdb2             322G  211G   96G  69% /backup/archive
              
              1 Reply Last reply Reply Quote 0
              • ajin.cA
                ajin.c
                last edited by scottalanmiller

                du -shx /*

                out put keeps on counting .........

                36K     /backup
                6.4M    /bin
                43M     /boot
                772K    /dev
                29M     /etc
                

                and so onn

                scottalanmillerS 1 Reply Last reply Reply Quote 0
                • ajin.cA
                  ajin.c
                  last edited by

                  root@trvbackup [~]# du -smx * | sort -n
                  1 anaconda-ks.cfg
                  1 CHANGELOG
                  1 cpanel3-skel
                  1 installer.lock
                  1 install.log
                  1 install.log.syslog
                  1 install.sh
                  1 latest
                  1 LICENSE
                  1 php.ini.new
                  1 php.ini.orig
                  1 public_ftp
                  1 public_html
                  1 README
                  1 scripts
                  1 tmp
                  3 csf

                  scottalanmillerS 1 Reply Last reply Reply Quote 0
                  • ajin.cA
                    ajin.c
                    last edited by

                    trying on it......

                    1 Reply Last reply Reply Quote 0
                    • scottalanmillerS
                      scottalanmiller @ajin.c
                      last edited by

                      @ajin.c said:

                      du -shx /*

                      out put keeps on counting .........

                      36K /backup
                      6.4M /bin
                      43M /boot
                      772K /dev
                      29M /etc

                      and so onn

                      It takes a while if the system is full. The "and so on" is the part that is important.

                      1 Reply Last reply Reply Quote 0
                      • scottalanmillerS
                        scottalanmiller @ajin.c
                        last edited by

                        @ajin.c said:

                        root@trvbackup [~]# du -smx * | sort -n
                        1 anaconda-ks.cfg
                        1 CHANGELOG
                        1 cpanel3-skel
                        1 installer.lock
                        1 install.log
                        1 install.log.syslog
                        1 install.sh
                        1 latest
                        1 LICENSE
                        1 php.ini.new
                        1 php.ini.orig
                        1 public_ftp
                        1 public_html
                        1 README
                        1 scripts
                        1 tmp
                        3 csf

                        You switched into root's home director "/root" which is not using any space. So this output won't help. You need to start at /. So do this...

                        cd /
                        du -smx * | sort -n

                        And provide the complete results.

                        1 Reply Last reply Reply Quote 0
                        • scottalanmillerS
                          scottalanmiller
                          last edited by

                          Adding keywords for anyone searching later: CentOS RHEL Red Hat Enterprise Linux

                          1 Reply Last reply Reply Quote 0
                          • scottalanmillerS
                            scottalanmiller
                            last edited by scottalanmiller

                            Here is some sample output from a web server I happen to be logged into at the moment. I added the "2> /dev/null" and the "tail" portions to make it easier to read and use. Make sure you are root before doing this to make things easy.

                            [root@to-lnx-web /]# **whoami**
                            root
                            [root@to-lnx-web /]# **pwd**
                            /
                            [root@to-lnx-web /]# **du -smx * 2> /dev/null| sort -n | tail -n 5**
                            153     boot
                            403     tmp
                            554     lib
                            899     usr
                            6070    var
                            [root@to-lnx-web /]# **cd /var**
                            [root@to-lnx-web var]# **du -smx * 2> /dev/null| sort -n | tail -n 5**
                            70      tmp
                            73      spool
                            184     lib
                            1708    www
                            3957    log
                            [root@to-lnx-web var]# **cd log**
                            [root@to-lnx-web log]# **du -smx * 2> /dev/null| sort -n | tail -n 5**
                            316     httpd
                            413     maillog-20140223
                            627     maillog
                            1043    maillog-20140302
                            1267    maillog-20140309
                            
                            1 Reply Last reply Reply Quote 0
                            • scottalanmillerS
                              scottalanmiller
                              last edited by

                              From my output above, you can see that I started in / and found that var was the directory using the most space under it. So I moved into var and did it again. Under var we saw that log was using the most space. So we moved until log and ran it again.

                              The 2>/dev/null removes extraneous error output that you don't care about.

                              The sort -n | tail -n 5 portion shows you only the five largest files or directories from each run. You could adult the "5" to "8" or "12" or whatever is most useful to you.

                              1 Reply Last reply Reply Quote 0
                              • ajin.cA
                                ajin.c
                                last edited by

                                root@trvbackup [/]# du -smx * | sort -n
                                ^C
                                root@trvbackup [/]#

                                Waited arround half an hour ...but no output ....still waiting

                                1 Reply Last reply Reply Quote 0
                                • scottalanmillerS
                                  scottalanmiller
                                  last edited by

                                  If the drive is full, this will likely take some time. Because it is sorting the output it will show nothing until it completes.

                                  1 Reply Last reply Reply Quote 0
                                  • ajin.cA
                                    ajin.c
                                    last edited by

                                    Boss.....Still waiting for the output.......

                                    1 Reply Last reply Reply Quote 0
                                    • ajin.cA
                                      ajin.c
                                      last edited by

                                      root@trvbackup [/]# du -smx * | sort -n
                                      du: cannot access proc/11877/task/11877/fd/4': No such file or directory du: cannot access proc/11877/task/11877/fdinfo/4': No such file or directory
                                      du: cannot access proc/11877/fd/4': No such file or directory du: cannot access proc/11877/fdinfo/4': No such file or directory
                                      0 proc
                                      0 scripts
                                      0 sys
                                      1 backup
                                      1 dev
                                      1 lost+found
                                      1 media
                                      1 mnt
                                      1 quota.user
                                      1 razor-agent.log
                                      1 selinux
                                      1 srv
                                      3 tmp
                                      7 bin
                                      8 root
                                      14 sbin
                                      29 etc
                                      30 lib64
                                      38 opt
                                      43 boot
                                      234 lib
                                      5401 usr
                                      17480 var
                                      148041 home

                                      1 Reply Last reply Reply Quote 0
                                      • scottalanmillerS
                                        scottalanmiller
                                        last edited by

                                        This is easy. It's someone storing stuff in their home directory. This is not a system problem but a user problem. Just just the same command but with /home instead of just / and it will produce the list of your offending users.

                                        1 Reply Last reply Reply Quote 0
                                        • scottalanmillerS
                                          scottalanmiller
                                          last edited by

                                          That is 148GB of user data.

                                          1 Reply Last reply Reply Quote 0
                                          • ajin.cA
                                            ajin.c
                                            last edited by

                                            root@trvbackup [/home]# du -smx * | sort -n

                                            right ?

                                            scottalanmillerS 2 Replies Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post