1

I've reached a point where mongo fails to start because there's no enough free disk space. The log suggests using the --smallfiles option to start the mongod service.

So, I have two options, either make the hard drive bigger (it's an Amazon free instance) or doing what the mongodb log suggested.

Would data get corrupted if I enable --smallfiles for an existing mongo instance? I wouldn't want to lose any data.

2

Straight to the point? The smallfiles option doesn't help. It doesn't automagically shrink existing files. All this option does is changing the behavior of how data files are preallocated.

Usually, the first datafile allocated has a size of 64MB. The next has 128MB. This doubling goes on until 2GB are reached. After that, every new datafile is allocated with 2GB.

The smallfiles option simply sets the initial size to 16MB, and the doubling starts from there.

You need either to increase disk space or start to shard.

  • Thanks Markus! Then I guess that, while it wouldn't actually fix my problem, smallfiles won't screw my existing data. I want to be sure about that because I might enable it after increasing disk space. – Silvestre Herrera Sep 15 '15 at 2:53
  • @Silvestre the you didn't get me right. The smallfiles option won't help at all for existing databases. And for new ones, I heavily doubt it's use. You are saving a few MB at best. Most real world indices are much bigger. The smallfiles option was introduced for things like integration or cluster tests on space confined machines like VMs. – Markus W Mahlberg Sep 15 '15 at 8:12
  • Oh, no, I got you. I understand that it won't help me and I need to either increase the disk size or start sharding. I'm by no means a specialist on databases, I'm more like a monkey punching a keyboard and somehow I sometimes write code that mostly works. LOL. I just wanted to know if enabing the option would have any impact on existing data. – Silvestre Herrera Sep 15 '15 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.