# About mount a remote smb share for Syncthing in Jail



## esingress (Jun 21, 2021)

Hi all,

I want to mount a remote smb share in Syncthing (Jail), but it seems not work.

I have a remote smb share (Server01, 192.168.0.1) and a Server02 (192.168.0.2)
And install a Syncthing in Jail (192.168.0.3)

Server01 - 192.168.0.1
Server02 - 192.168.0.2
Syncthing (Jail) - 192.168.0.3

Server01 is a remote smb server not a FreeBSD server
Server02 version: FreeBSD 12.2

Here what i done.

Since it cannot direct mount a smb in jails, so I make a directory in Server02
- /mnt/Server01

Mount smb share (Server01) in Server02, not in jails
- `mount_smbfs -u 983 -g 983 -d 770 -f 770 -I 192.168.0.1 //user01@Server01/folder01 /mnt/Server01`
which "983" is the UID and GID of syncthing.
and "user01" have full permission right to "folder01" and subfolder

and add a Mount point in Jails
- /mnt/Server01 to /mnt/iocage/jails/Syncthing/root/mnt/Server01

Restart Syncthing

Check the user right in Syncthing console, use ls -sl, it shows


```
total 17
1 drwxrwx---+ 3 syncthing  syncthing      3 Jun 15 15:29 InternalStorage
16 drwxrwx---  1 syncthing  syncthing  16384 Jun 17 15:18 Server01
```

it seems same as the original folder right.

But Syncthing cannot sync the file to Server01, it said permission denied with "syncing: rename"
It can sync file to Server02 folder (i.e. InternalStorage).

And in console, as root@Syncthing, I can create file in /mnt/Server01, but cannot remove or rename the file.

I try login Server02 ssh with 'user01". (i.e. the user mount the remote smb server on Server01 & have the full permission right to  "folder01" on Server01 and subfolder)
and test the mount point (i.e. /mnt/Server01),
I can 'touch', 'rm' and 'mv' the file.

But when I enter the console of Syncthing in Server02 Jail, (root@Syncthing)
I can 'touch' a file only but cannot 'rm' and 'mv' the file.

And here is theoutput of iocage fstab -e Syncthing

```
/mnt/Disk2/Syncthing    /mnt/Disk1/iocage/jails/Syncthing/root/mnt/Syncthing    nullfs  rw      0       0
/mnt/Server01               /mnt/Disk1/iocage/jails/SyncThing/root/mnt/Server01      nullfs  rw      0       0
```

I set a password of 'syncthing' in Server02 ,
And test the mount point outside the jails,
it also can 'touch', 'rm' and 'mv' the file.

And Hints?  Thanks!


----------



## esingress (Jun 22, 2021)

When I try to Sync files, it seems can transfer to the Server01, but it cannot finalize the file

After Sync fail, use ls -sl the /mnt/Server01, it shows


```
root@Syncthing:/mnt/Server01 # ls -sl
total 79
16 drwxrwx---  1 syncthing  syncthing  16384 Jun 22 14:25 .stfolder
31 -rwxrwx---  1 syncthing  syncthing  31554 Jun 22 13:39 .syncthing.test.pdf.tmp
16 drwxrwx---  1 syncthing  syncthing  16384 Jun 22 13:39 Print
16 drwxrwx---  1 syncthing  syncthing  16384 Jun 22 13:39 test
```

Double checked the file on Server01, those tmp file (i.e. .syncthing.test.pdf.tmp) and ".stfolder" are existed

I also try mount Server01 when jail start by edit fstab


```
//user01@Server01/folder01 /mnt/Disk1/iocage/jails/Syncthing/root/mnt/Server01 smbfs rw,-N,-I192.168.0.1,-u983,-g983,-d770,-f770  0 0
```

It still not work.

Thanks!


----------



## esingress (Jun 23, 2021)

OK. Maybe I found the problem.

On the Server01 smb,
I add a line in smb.conf


> share modes = no



I don't know It is the problem cause the Syncthing not work or it make the FreeBSD server cannot mount the remote smb Server properly.

Now, Syncthing can upload the file to Server01


----------

