Calibre, Calibre-Web with a network share

A lot of people do report issues with the Calibre database when the database is on a NAS or network drive. Last week I had issues with Calibre-Web and the validation of the database when Calibre and Calibre-web do maintenance on the database.

People get: “CantOpenError: CantOpenError: unable to open database file”

Within the comments the git repository of Calibre-web I got a hint.  and that solved my issue
a number of years I was running a 13K ebook database, but I was never satisfied. Adding books was almost impossible without syncing, copying books, move the database and messing up the database with duplicates. Terrible.

Last week the database was not able to fix itself anymore and I decided to start over with only those books I really like or wanted to keep. And I wanted to fix the database issues.

To fix it, you must be able to run a NAS or (virtual) Server with SAMBA version1 (NT1).  As I am running VMWARE a new Linux Server was built quickly. Please be noticed that I do not care about security in my home network on that machine and for that purpose.

Import configuration steps in /etc/samba/smb.conf

min protocol = NT1
max protocol = NT1
client min protocol = NT1
client max protocol = NT1
# this will run samba in Samba Version 1 mode.

force user = [a-username]
path = /var/www/html/books
writeable = yes
browseable = yes
guest ok = yes
guest account = [a-username]
create mask = 0777
directory mask = 0777
oplocks = false
level2 oplocks = false
# Especially the oplocks on false are needed. If not Calibre-Web will not get access to the database if Calibre is using it. If that happens your database can be corrupted again very quickly.

If you run Calibre under Windows 10 make sure you add SMB1 support through the ‘features’ option this is disabled by default.

I started with 400 books and now I added 520 books in many sessions without any open database issue.

Using the oplocks on false could be also a solution when using SMBv3 or SMBv4 but I did not try that.

Please also notice that the writer of Calibre does not suggest to use a network share and it is known that for some it is working fine and for others not. This blog items could lead to more solution(s). Even it is not supported ;)