Syncthing and folder permisions

Having issues with your DietPi installation or found a bug? Post it here.
Post Reply
da1k
Posts: 5
Joined: Wed Aug 18, 2021 4:11 pm

Syncthing and folder permisions

Post by da1k »

Hello,

I'm using DietPi for some time and it works very well. Today I installed Syncthing (via DietPi-Software)to sync some data. Installation went well, I can connect via web interface but when I'm adding folder to sync I receive:

Code: Select all

Failed to create folder marker: mkdir /mnt/m2/.stfolder: permission denied
As I understood the problem is with folder permissions. I already found that Syncthing uses dietpi user by default and it's ok for me. But how can I add dietpi user to be able read and write in /mnt/m2 without changing privilages of other users?

ls -l gives that:

Code: Select all

pcbackup@T620:/mnt/m2$ ls -l
total 360
drwxrwxr-x 3 root     root   4096 Aug 18 11:34 dietpi-backup
drwx------ 2 root     root  16384 Jul 23 11:45 lost+found
drwxr-xr-x 2 pcbackup root 344064 Aug 17 22:52 DIR1
drwxr-xr-x 2 pcbackup root   4096 Jul 23 11:51 DIR2
User avatar
Joulinar
Posts: 5619
Joined: Sat Nov 16, 2019 12:49 am

Re: Syncthing and folder permisions

Post by Joulinar »

Hi,

short question. /mnt/m2 is an axternal disk? Is it ext4 file system format? Can you check?

Code: Select all

lsblk -o name,fstype,label,size,ro,type,mountpoint,partuuid,uuid
ls -la /mnt/m2
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
da1k
Posts: 5
Joined: Wed Aug 18, 2021 4:11 pm

Re: Syncthing and folder permisions

Post by da1k »

It's internal M.2 Sata drive with one partition formated to ext4

Code: Select all

lsblk -o name,fstype,label,size,ro,type,mountpoint,partuuid,uuid
sdb                      447.1G  0 disk                                                  
\u2514\u2500sdb1 ext4              447.1G  0 part /mnt/m2

Code: Select all

ls -la /mnt/m2
total 368
drwxrwxr-x 6 root     root   4096 Aug 18 14:06 .
drwxr-xr-x 8 root     root   4096 Aug 18 14:18 ..
drwxrwxr-x 3 root     root   4096 Aug 18 11:34 dietpi-backup
drwx------ 2 root     root  16384 Jul 23 11:45 lost+found
drwxr-xrw- 2 pcbackup root 344064 Aug 17 22:52 DIR1
drwxr-xr-x 2 pcbackup root   4096 Jul 23 11:51 DIR2
User avatar
Joulinar
Posts: 5619
Joined: Sat Nov 16, 2019 12:49 am

Re: Syncthing and folder permisions

Post by Joulinar »

ok the entire folder /mnt/m2 is writable to user root only. You would need to change owner for this mount point to user dietpi

Code: Select all

chown dietpi:dietpi /mnt/m2/
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
da1k
Posts: 5
Joined: Wed Aug 18, 2021 4:11 pm

Re: Syncthing and folder permisions

Post by da1k »

If I will change owner will it have imapact for something else?

EDIT: I tried and it's better ;) Now I have this:

Code: Select all

XYZ sync	failed to setup inotify handler. Please increase inotify limits, see https://docs.syncthing.net/users/faq.html#inotify-limits
I follow link and from root account input this:

Code: Select all

echo "fs.inotify.max_user_watches=204800" | sudo tee -a /etc/sysctl.conf


I also restart Syncthing but it didn't help. Should I restart Dietpi also?
User avatar
Joulinar
Posts: 5619
Joined: Sat Nov 16, 2019 12:49 am

Re: Syncthing and folder permisions

Post by Joulinar »

Hi,

there is following statement on the link you shared
This only takes effect after a reboot.
So yes, a reboot might be required
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
da1k
Posts: 5
Joined: Wed Aug 18, 2021 4:11 pm

Re: Syncthing and folder permisions

Post by da1k »

I was away for few days ...

When I rebooted computer now I get:

Code: Select all

error while traversing /mnt/m2/dietpi-backup/data/root: permission denied
It's a folder when I make DietPi system drive backup. Should I change owner also? Will it interupt backup?
User avatar
Joulinar
Posts: 5619
Joined: Sat Nov 16, 2019 12:49 am

Re: Syncthing and folder permisions

Post by Joulinar »

Where does the issue/error is shown?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
da1k
Posts: 5
Joined: Wed Aug 18, 2021 4:11 pm

Re: Syncthing and folder permisions

Post by da1k »

in a frame in main window just before "folders" and "this device"
User avatar
Joulinar
Posts: 5619
Joined: Sat Nov 16, 2019 12:49 am

Re: Syncthing and folder permisions

Post by Joulinar »

ok, I guess I know what you are trying to do. You are trying to save DietPi backup via Syncthing. Correct?

This might not be working on a default setup because Syncthing is executed as user dietpi and will not have access to folders that are accessible by user root only, like the root user home directory.

Something I'm not recommending is to execute Syncthing as root user. As well Syncthing themselves will complain about it

Code: Select all

2021-08-25 22:03:41: Syncthing should not run as a privileged or system user. Please consider using a normal user account.
But it should work.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply