Reclaim Mongodb Diskspace

Mongodb chews through disk space.  Even our lightly used servers need to be cleared out every couple of months.  The new usePowerOf2Sizes flag has helped but it hasn’t eliminated our need to perform a full --repair every once in a while.  Unfortunately, the process requires downtime and even more free space than Mongo has consumed, but after mounting a temporary volume (i.e. /mnt below) it will compact all databases and release a significant portion of the disk.

sudo mongod --config /etc/mongo.conf --shutdown
sudo mongod --config /etc/mongo.conf --repair --nojournal --repairpath /mnt

Leave a comment