Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 3813  / 1 Year ago, sat, march 18, 2023, 11:43:43

I have 120 GB SSD Drive with two partitions (NTFS with Windows and ext4 with Ubintu) and 2TB NTFS HDD shared between Windows and Ubuntu.



I configured my HDD to be properly mounted on system boot:



# /etc/fstab: static file system information.
UUID=B400515500512022 /media/B400515500512022 ntfs-3g auto,users,uid=1000,gid=1001,fmask=113,dmask=002,utf8 0 0


I also created special group (gid=1001) to handle permissions and added mongodb user to it:



ntfsdrive:x:1001:leonid,mongodb


So, now ntfsdrive group have proper permissions (rw for files and rwx for directories) for the whole drive, including mongodb folder:



drwxrwxr-x 1 leonid ntfsdrive       4096 Feb  6 12:51 mongodb


But mongodb still refuses to run on this drive:



Wed Feb  6 12:51:31 [initandlisten] MongoDB starting : pid=7480 port=27017 dbpath=/media/B400515500512022/mongodb 64-bit host=ubuntu
Wed Feb 6 12:51:31 [initandlisten] db version v2.2.3, pdfile version 4.5
Wed Feb 6 12:51:31 [initandlisten] git version: f570771a5d8a3846eb7586eaffcf4c2f4a96bf08
Wed Feb 6 12:51:31 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Wed Feb 6 12:51:31 [initandlisten] options: { config: "/etc/mongodb.conf", dbpath: "/media/B400515500512022/mongodb", logappend: "true", logpath: "/var/log/mongodb/mongodb.log" }
Wed Feb 6 12:51:31 [initandlisten] journal dir=/media/B400515500512022/mongodb/journal
Wed Feb 6 12:51:31 [initandlisten] recover : no journal files present, no recovery needed
Wed Feb 6 12:51:31 [initandlisten] info preallocateIsFaster couldn't run due to: couldn't open file /media/B400515500512022/mongodb/journal/tempLatencyTest for writing errno:1 Operation not permitted; returning false
Wed Feb 6 12:51:31 [initandlisten] exception in initAndListen: 13516 couldn't open file /media/B400515500512022/mongodb/journal/j._0 for writing errno:1 Operation not permitted, terminating
Wed Feb 6 12:51:31 dbexit:
Wed Feb 6 12:51:31 [initandlisten] shutdown: going to close listening sockets...
Wed Feb 6 12:51:31 [initandlisten] shutdown: going to flush diaglog...
Wed Feb 6 12:51:31 [initandlisten] shutdown: going to close sockets...
Wed Feb 6 12:51:31 [initandlisten] shutdown: waiting for fs preallocator...
Wed Feb 6 12:51:31 [initandlisten] shutdown: lock for final commit...
Wed Feb 6 12:51:31 [initandlisten] shutdown: final commit...
Wed Feb 6 12:51:31 [initandlisten] shutdown: closing all files...
Wed Feb 6 12:51:31 [initandlisten] closeAllFiles() finished
Wed Feb 6 12:51:31 [initandlisten] journalCleanup...
Wed Feb 6 12:51:31 [initandlisten] removeJournalFiles
Wed Feb 6 12:51:31 [initandlisten] shutdown: removing fs lock...
Wed Feb 6 12:51:31 dbexit: really exiting now


I have no problems running mongodb with the same configuration (including mongodb folder permissions) on my ext4 drive.



Is there a way to solve this problem, or my only option is to add ext4 partition to my HDD drive?


More From » permissions

 Answers
4

Having replicated this myself, it appears that using the mount options you specify allows the mongodb user to write to the NTFS volume, but there is something specific that MongoDB is trying to do with the files that is not permitted by these options; perhaps it cannot set the umask or ownership on its files exactly how it wants to.



The solution is to use the permissions option when mounting the NTFS volume rather than specifying the owner explicitly. See the ntfs-3g man page for further details.



So /etc/fstab would look like this:



UUID=B400515500512022 /media/B400515500512022 ntfs-3g defaults,locale=en_US.UTF-8,permissions 0 0


On a fresh NTFS volume mounted at /media/B400515500512022, you can then run:



sudo mkdir /media/B400515500512022/mongodb
sudo chown mongodb:mongodb /media/B400515500512022/mongodb


before running:



sudo -u mongodb mongod --dbpath /media/B400515500512022/mongodb


You may wish to check that this does not cause problems when accessing the files from Windows.


[#32819] Sunday, March 19, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sipwing

Total Points: 245
Total Questions: 100
Total Answers: 118

Location: Aland Islands
Member since Thu, Oct 22, 2020
4 Years ago
sipwing questions
Sun, May 29, 22, 22:00, 2 Years ago
Fri, Jun 24, 22, 08:46, 2 Years ago
Fri, Dec 23, 22, 00:04, 1 Year ago
;