Syncthing still putting the database in root despite -home flag

I have been trying to get Syncthing to stop putting the database in the root directory using the -home flag as others have recommended and then pointing it toward the external hard drive. Despite doing this it still puts the database in the root or overlay directory even with the -home flag and pointing to a valid directory. I can't find anything in the configuration file to prevent this from happening. I am synchronizing over 100 GB of files which means a large database and as soon as it creates the database Syncthing crashes because of being out of storage space in the root directory which it should NOT be putting the database in at all because of the -home flag.

I didn't try the home option, I just made a link from the default in /etc to the USB drive and forgot about it until just now.

$ ln -s /mnt/sda1/syncthing /etc/syncthing

In the config.xml I point to another directory on the USB drive, like this (each synced drive looks pretty much the same, with /syncthing_data/xxx changed in the folder spec).

$ grep folder /etc/syncthing/*
config.xml:    <folder id="defaultsync" label="Default" path="/syncthing_data/Sync" type="sendreceive" rescanIntervalS="3600" fsWatcherEnabled="true" fsWatcherDelayS="10" ignorePerms="false" autoNormalize="true">

The home option does not work, I have been trying it for months and it always results in a database that fills up the router's internal storage because it ignores the directory I specify and causes the program to crash along with preventing the installation of additional packages. Edit: the link does not work either, I just tried it and the database still fills up the internal storage on the router.

Hmm, strange that linking doesn't work for you, I've had it set up this way and working on an RT3200 for like a year and a half without issues.

Looking at it now, I see that I did change ownership on the db directory.

$ ll /mnt/sda1/
drwx------    3 syncthin syncthin      4096 Nov 21 00:12 syncthing/

$ ll /mnt/sda1/syncthing/
drwx------    3 syncthin syncthin      4096 Nov 21 00:12 ./
drwxr-xr-x    6 syncthin syncthin      4096 Mar 10  2022 ../
-rw-r--r--    1 syncthin syncthin       794 Feb 20  2022 cert.pem
-rw-------    1 syncthin syncthin     10305 Mar 13  2022 config.xml
-rw-------    1 syncthin syncthin       825 Nov 16 18:50 csrftokens.txt
-rw-r--r--    1 syncthin syncthin       782 Feb 20  2022 https-cert.pem
-rw-------    1 syncthin syncthin       288 Feb 20  2022 https-key.pem
drwxr-xr-x    2 syncthin syncthin      4096 Nov 21 00:16 index-v0.14.0.db/
-rw-------    1 syncthin syncthin       288 Feb 20  2022 key.pem

So you might have to go to your external drive and do this (where /mnt/sda1 is wherever your mount point lives on your machine).

$ chown -R syncthing:syncthing /mnt/sda1/syncthing

Ok, I just set up syncthing on another machine and found the bug. The init script does not handle either the home or gui_address properly when starting the service:

$ ps ww | grep syncthing
11996 syncthin 1220m SN   /usr/bin/syncthing serve --gui-address=http://0.0.0.0:8384 --home=/etc/syncthing --logfile=/mnt/sda2/syncthing/syncthing.log --no-browser --gui-address=http://10.1.2.1:8384 --home=/mnt/sda2/syncthing --log-max-old-files=7 --log-max-size=1048576 --no-default-folder

If you edit /etc/init.d/syncthing and change line 17 from:

		enabled|macprocs|nice|user|logfile)

to

        enabled|gui_address|home|logfile|macprocs|nice|user)

Then we get proper behavior with those parameters being supplied just once, and .

$ /etc/init.d/syncthing restart

$ ps ww | grep syncthing
30786 syncthin 1220m SN   /usr/bin/syncthing serve --gui-address=http://10.1.2.1:8384 --home=/mnt/sda2/syncthing --logfile=/mnt/sda2/syncthing/syncthing.log --no-browser --log-max-old-files=7 --log-max-size=1048576 --no-default-folder

$ ll /mnt/sda2/
drwxr-xr-x    5 root     root          4096 Nov 26 01:28 ./
drwxr-xr-x    1 root     root           224 Dec 31  1969 ../
drwx------    2 root     root         16384 May 31 08:49 lost+found/
drwxr-xr-x    3 syncthin syncthin      4096 Nov 26 01:29 sync_data/
drwx------    3 syncthin syncthin      4096 Nov 26 01:35 syncthing/

$ ll /mnt/sda2/syncthing/
drwx------    3 syncthin syncthin      4096 Nov 26 01:35 ./
drwxr-xr-x    5 root     root          4096 Nov 26 01:28 ../
-rw-r--r--    1 syncthin syncthin       794 Nov 26 01:22 cert.pem
-rw-------    1 syncthin syncthin      9062 Nov 26 01:35 config.xml
-rw-------    1 syncthin syncthin      6408 Nov 26 01:22 config.xml.v0
-rw-------    1 syncthin syncthin       297 Nov 26 01:25 csrftokens.txt
-rw-r--r--    1 syncthin syncthin       786 Nov 26 01:22 https-cert.pem
-rw-------    1 syncthin syncthin       288 Nov 26 01:22 https-key.pem
drwxr-xr-x    2 syncthin syncthin      4096 Nov 26 07:12 index-v0.14.0.db/
-rw-------    1 syncthin syncthin       288 Nov 26 01:22 key.pem
-rw-r--r--    1 syncthin syncthin     18383 Nov 26 07:12 syncthing.log

Edit: Here's my config for all of this post.

$ uci show syncthing
syncthing.syncthing=syncthing
syncthing.syncthing.enabled='1'
syncthing.syncthing.gui_address='http://10.1.2.1:8384'
syncthing.syncthing.home='/mnt/sda2/syncthing'
syncthing.syncthing.nice='19'
syncthing.syncthing.macprocs='0'
syncthing.syncthing.user='syncthing'
syncthing.syncthing.logfile='/mnt/sda2/syncthing/syncthing.log'
syncthing.syncthing.log_max_old_files='7'
syncthing.syncthing.log_max_size='1048576'
syncthing.syncthing._no_default_folder='1'
1 Like

Reported: https://github.com/openwrt/packages/issues/22760

1 Like

I don't see any options in the config.xml file to change the configuration of the home directory or the logfile directory but did in the /config/init.d/syncthing file and changed those but it still shows the home directory as /etc/syncthing which is putting the files on the router's internal storage.

What does the ps line look like after restarting syncthing? Run these three commands and post your results:

uci show syncthing
/etc/init.d/syncthing restart
ps www | grep syncthing

The bug fix has been in snapshot for a few days (and backported to 23.05 about 12 hours before I'm posting this), but hasn't made it through the build yet. When you see the package version bump up to 1.24.0-2 or later ("or later" might be 1.25.0-1 or 1.27.1-1 or something like that), then try reinstalling and testing.

$ opkg update
$ opkg -A info syncthing | grep Version
Version: 1.24.0-2

Edit: Here's the link to the commit with the fix:

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.