directory index full

How to handle “Directory index full” messages in syslog

kernel: EXT3-fs warning (device dm-3): ext3_dx_add_entry: Directory index full!

On systems in which this is being constantly logged to syslog, this can become rather annoying, but it is not a bug. It’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)

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’ve put together this quick script to tell me where to start looking:

#!/bin/bash
# Kristian Reese
# http://kristianreese.com

for veid in $(vzlist -aHh 0*.tld.com -o veid)
do
echo $veid
vzctl exec $veid 'find /var -type d 2>/dev/null |

(
while read dir; do cnt=`ls -l "$dir" | wc -l`

if [ "$cnt" -gt "10000" ]; then
echo "$cnt: $dir"
fi

done
)'

echo
done
Share