I recently had to move a MongoDB installation (well, at least the actual data) to a larger hard drive with as little downtime as possible.

According to the mighty Stack Overflow you can either just create a symlink or actually move the data and adjust the configuration. Since I believe that explicit configurations (i.e. not having to remember that a symlink is in place) are less painful in the long-run, I opted for the second option.

For a simple setup without Sharding this works perfectly fine (Ubuntu 16.04 Server):

service mongod stop

mkdir /mnt/mongodb/data
chown mongodb:mongodb /mnt/mongodb/data/
vim /etc/mongod.conf #change dbPath to /mnt/mongodb/data/mongodb

mv /var/lib/mongdb/ /mnt/mongodb/data/

service mongod start


Make sure to set the permissions correctly and stop the server before moving the data. Moving/Copying the data while the server is running will almost certainly result in unwanted behaviour ;). You should also think about relocating the logfiles by editing mongod.conf. Ideally, the downtime can be reduced to the amount of time the actual moving of the data takes.