Cheng Hui's Website

Why nobrl for mount.cifs

What happened?

In the progress of setting up Picoshare (image/video hosting website) for this blog, I was stumped with the following error that caused the container to crash every single time it was launched.

picoshare_1  | 2023/03/11 09:47:27 sqlite.go:48: failed to set pragmas: database is locked                                        

I'm mounting an online storage using cifs to my server, and other containerized applications have no problem accessing it, but why is this?

After a quick search and debugging, the problem seems to be caused by the byte-range lock imposed on the mount by default.

Solution

Now that the problem is known, the command for mounting becomes the following after adding the nobrl flag.

mount.cifs -o user=username,pass=iampassword,iocharset=utf8,file_mode=0774,dir_mode=0774,nobrl //securestorage.com/folder /media/storage

Should I include nobrl everywhere?

Well, probably not. The byte-range lock is on by default for a reason, and should only be disabled if there's a reason to do so.

By turning the lock off, there's a risk of data corruption and inconsistencies, especially when multiple users actively use the mount.