{"id":4168,"date":"2015-01-27T19:20:08","date_gmt":"2015-01-27T11:20:08","guid":{"rendered":"http:\/\/rmohan.com\/?p=4168"},"modified":"2015-01-27T19:20:08","modified_gmt":"2015-01-27T11:20:08","slug":"ext3-fs-warning-directory-index-full","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=4168","title":{"rendered":"EXT3-fs warning Directory index full!"},"content":{"rendered":"<p>At times, I come across the following message in syslog:<br \/>\nkernel: EXT3-fs warning (device dm-3): ext3_dx_add_entry: Directory index full!<\/p>\n<p>On systems in which this is being constantly logged to syslog, this can become rather annoying, but it is not a bug.  It&#8217;s informing the user that somewhere within the system, a directory has more than 32,000 subdirectories.  A directory can have at most 31998 subdirectories, because an inode can have at most 32000 links.  (See external link below for source)<\/p>\n<p>Sometimes, this can be difficult to find, especially in a case whereby a physical server is hosting a couple of hundres VPS accounts.  To help break down where the culprit(s) is coming from, I&#8217;ve put together this quick script to tell me where to start looking:<\/p>\n<p>#!\/bin\/bash<br \/>\n# Kristian Reese<br \/>\n# http:\/\/kb.kristianreese.com<\/p>\n<p>for veid in $(vzlist -aHh 0*.tld.com -o veid)<br \/>\ndo<br \/>\n  echo $veid<br \/>\n  vzctl exec $veid &#8216;find \/var -type d 2>\/dev\/null |<\/p>\n<p>  (<br \/>\n    while read dir; do cnt=`ls -l &#8220;$dir&#8221; | wc -l`<\/p>\n<p>    if [ &#8220;$cnt&#8221; -gt &#8220;10000&#8221; ]; then<br \/>\n      echo &#8220;$cnt: $dir&#8221;<br \/>\n    fi<\/p>\n<p>    done<br \/>\n  )&#8217;<\/p>\n<p>echo<br \/>\ndone<br \/>\nMost of the time, customer emails are queued up in their qmail mailboxes.  I&#8217;ll investigate to see what these emails are.  For example, in one particular case, I found the customer was running a cronjob to check the status of httpd every waking moment of uptime.  The crontab did not output to \/dev\/null, and therefore emails were being sent each and everytime the crontjob ran.  This script was named &#8220;keep-apache-alive&#8221; and was subjected as such in the emails, so I looked to see how many of these there were in the users \/var\/qmail\/mailnames\/domain.com\/info\/Maildir\/new.  There were a LOT, so I blew them away and fixed cron to output to \/dev\/null, preventing the cronjob from sending emails.<\/p>\n<p>-bash-3.1# find . -type f -exec cat {} \\; | grep &#8220;keep-apache-alive&#8221; | wc -l<br \/>\n-bash-3.1# find . -type f -exec grep -q &#8220;keep-apache-alive&#8221; {} \\; -exec rm {} \\; -exec echo removed {} \\;<br \/>\n-bash-3.1# find . -type f -exec cat {} \\; | grep Subject | more<\/p>\n<p>Another method would be to use the following bit of perl code:<\/p>\n<p>#!\/usr\/bin\/perl<br \/>\nuse File::Find;<br \/>\nmy %dirs = ();<br \/>\nfind<br \/>\n(<br \/>\n  sub<br \/>\n  {<br \/>\n   unless(-d $_) { $dirs{$File::Find::dir}++; }<br \/>\n  }, &#8216;.&#8217;<br \/>\n);<\/p>\n<p>foreach(keys %dirs) {<br \/>\n if ($dirs{$_} > 20000) {<br \/>\n    print &#8220;$_ has $dirs{$_} files.\\n&#8221;;<br \/>\n }<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At times, I come across the following message in syslog: kernel: EXT3-fs warning (device dm-3): ext3_dx_add_entry: Directory index full!<\/p>\n<p>On systems in which this is being constantly logged to syslog, this can become rather annoying, but it is not a bug. It&#8217;s informing the user that somewhere within the system, a directory has more than [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,17],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4168"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4168"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4168\/revisions"}],"predecessor-version":[{"id":4169,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4168\/revisions\/4169"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}