(Ubuntu) Tried to move my MongoDB database to an external drive and now it throws errors

Posted on

Question :

I can run mongodb fine from my internal drive but if I try to set the --dbpath to my external drive, I get the following error:

2017-10-17T17:12:36.091-0500 [initandlisten] MongoDB starting : pid=30644 port=27017 dbpath=/home/data/database 64-bit host=machine
2017-10-17T17:12:36.092-0500 [initandlisten] db version v2.6.12
2017-10-17T17:12:36.092-0500 [initandlisten] git version: d73c92b1c85703828b55c2916a5dd4ad46535f6a
2017-10-17T17:12:36.092-0500 [initandlisten] build info: Linux build5.ny.cbi.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2017-10-17T17:12:36.092-0500 [initandlisten] allocator: tcmalloc
2017-10-17T17:12:36.092-0500 [initandlisten] options: { net: { port: 27017 }, storage: { dbPath: "/home/data/database" } }
2017-10-17T17:12:36.096-0500 [initandlisten] journal dir=/home/data/database/journal
2017-10-17T17:12:36.096-0500 [initandlisten] recover : no journal files present, no recovery needed
2017-10-17T17:12:36.096-0500 [initandlisten] LogFile::synchronousAppend failed with 8192 bytes unwritten out of 8192 bytes;  b=0x467a000 errno:5 Input/output error
2017-10-17T17:12:36.096-0500 [initandlisten] Fatal Assertion 13515
2017-10-17T17:12:36.104-0500 [initandlisten] 0x121df81 0x11bd689 0x11a019d 0x11bdae8 0xa765bd 0xa76bb5 0xa76e55 0xa6a61a 0x76e726 0x76f53b 0x76fb85 0x76fe59 0x7f8636ba9830 0x766419 
 mongod(_ZN5mongo15printStackTraceERSo+0x21) [0x121df81]
 mongod(_ZN5mongo10logContextEPKc+0x159) [0x11bd689]
 mongod(_ZN5mongo13fassertFailedEi+0xcd) [0x11a019d]
 mongod(_ZN5mongo7LogFile17synchronousAppendEPKvm+0x1a8) [0x11bdae8]
 mongod(_ZN5mongo3dur20_preallocateIsFasterEv+0x13d) [0xa765bd]
 mongod(_ZN5mongo3dur19preallocateIsFasterEv+0x25) [0xa76bb5]
 mongod(_ZN5mongo3dur16preallocateFilesEv+0x145) [0xa76e55]
 mongod(_ZN5mongo3dur7startupEv+0x5a) [0xa6a61a]
 mongod(_ZN5mongo14_initAndListenEi+0x456) [0x76e726]
 mongod(_ZN5mongo13initAndListenEi+0x1b) [0x76f53b]
 mongod() [0x76fb85]
 mongod(main+0x9) [0x76fe59]
 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f8636ba9830]
 mongod() [0x766419]
2017-10-17T17:12:36.104-0500 [initandlisten] 

***aborting after fassert() failure


2017-10-17T17:12:36.108-0500 [initandlisten] SEVERE: Got signal: 6 (Aborted).
Backtrace:0x121df81 0x121d35e 0x7f8636bbe4b0 0x7f8636bbe428 0x7f8636bc002a 0x11a020a 0x11bdae8 0xa765bd 0xa76bb5 0xa76e55 0xa6a61a 0x76e726 0x76f53b 0x76fb85 0x76fe59 0x7f8636ba9830 0x766419 
 mongod(_ZN5mongo15printStackTraceERSo+0x21) [0x121df81]
 mongod() [0x121d35e]
 /lib/x86_64-linux-gnu/libc.so.6(+0x354b0) [0x7f8636bbe4b0]
 /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38) [0x7f8636bbe428]
 /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a) [0x7f8636bc002a]
 mongod(_ZN5mongo13fassertFailedEi+0x13a) [0x11a020a]
 mongod(_ZN5mongo7LogFile17synchronousAppendEPKvm+0x1a8) [0x11bdae8]
 mongod(_ZN5mongo3dur20_preallocateIsFasterEv+0x13d) [0xa765bd]
 mongod(_ZN5mongo3dur19preallocateIsFasterEv+0x25) [0xa76bb5]
 mongod(_ZN5mongo3dur16preallocateFilesEv+0x145) [0xa76e55]
 mongod(_ZN5mongo3dur7startupEv+0x5a) [0xa6a61a]
 mongod(_ZN5mongo14_initAndListenEi+0x456) [0x76e726]
 mongod(_ZN5mongo13initAndListenEi+0x1b) [0x76f53b]
 mongod() [0x76fb85]
 mongod(main+0x9) [0x76fe59]
 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f8636ba9830]
 mongod() [0x766419]

It mentions a lot of system files and I once tried to mess with them when I tried to fix some Qt applications and bricked my system. So I’m hoping someone here knows anything about this?

My main internal drive was full and this database holds 500,000+ records of JSON (not private) so I can’t store it on my internal drive since this 1 collection takes up 250+GB. Yeah it’s a lot.

I have my 4TB drive that is storing all the data for my application. I tried to cp the folder into my external drive but when I try to run mongod --dbpath /path/to/file it throws this long error.

It works fine if I try to run it off a database on my internal drive. I changed permissions for my external drive and I read/write files to other folders on that drive all the time so I’m not sure why Mongodb doesn’t want to do it.

I even tried to symlink the external drive’s mounted location and then tried to run the mongo daemon with --dbpath pointed to the symlink which resides on my internal drive but it throws the same error.

Answer :

Format your external drive to some “native” Linux FS. EXT4 is good. This will solve your problem.

Thanks to JJussi for the answer.

I am on Ubuntu 16.04. Had an external drive with HFS+ format and MongoDB couldn’t read/write data to that drive because of the file system. I backed up the data, formatted as ext4 and now I can run a MongoDB database from it. Thanks!

Edit: Not sure if it was entirely necessary, but I easily did it by formatting with Disk Utility on my Mac and then switching to my Linux computer and formatting with GParted.

Leave a Reply

Your email address will not be published. Required fields are marked *