User Tools

Site Tools


It is possible to run out of inodes on a Linux file system, even if you have free space. The shamefulness of this engineering tradeoff aside, here's a script to (roughly) count inodes like du counts disk space:

import os,sys
def get_entry_count(path):
                for e in os.listdir(path):
                        p = os.path.join(path,e)
                        if os.path.isdir(p) and not os.path.ismount(p) and not os.path.islink(p):
                                r += get_entry_count(p)
                        r += 1
        except Exception,ex:
                sys.stderr.write("%s: %s\n"%(p,ex))
        print "%d  %s" % (r,path)
        return r
for root in sys.argv[1:]:

This code doesn't detect reused inodes (e.g. hard links), but it should be fine for any practical situation in which you've run out of inodes. Note that you can find the free inode count with "df -i".

running_out_of_inodes.txt · Last modified: 2014/01/24 10:00 by tkbletsc

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki