Delete empty directories to reclaim inodes

I was facing a situation on a server of ours ; the inode usage of one of our partitions was dangerously high (93%) and growing steadily.

This partition is quite big (~ 1 TB) and contains mainly a lot of pictures and their thumbnails. Here, a lot is about 50 millions pictures (originals and thumbnails).

Those pictures are stored by ID, partitioned to have no more than 999 sub-directories at each level. If a picture has the ID 1234567, it is stored (with its thumbnails) at
/srv/images/001/234/556/picture.jpg.

The problem is that when my app is deleting a picture, it deletes the files but doesn’t clean after itself, leaving a lot of empty directories. That’s why, we are using only 73% of the available disk space, but 93% of available inodes.

It occurred to us that a directory in the filesystem (ext3 for us) is consuming 2 inodes. Thanks to Evolix (our wonderful hosting partner) we’ve ran a quite simple command to delete those useless directories :

find -mindepth 1 -type d -empty -delete

with a watch 'df -i | grep /srv' we quickly saw the number of available inodes growing again.

Cet article, publié dans Autrement, Informatique, est tagué . Ajoutez ce permalien à vos favoris.

Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s