techlex
Cadet
- Joined
- Jul 17, 2019
- Messages
- 2
Hi,
I played with a new FreeNAS setup yesterday and also ran into the issue described already various times in these forums: After a reboot, the joined networks are lost, and the ID of the zerotier client changes.
Why does that happen?
Zerotier stores its runtime data in the directory
The steps needed to solve this are these:
Preparations
If you already have zerotier running on your FreeNAS Box, make sure to stop the daemon, it will not like with its data being juggled around:
Navigate to System ⯈ Tunables
Remove the
Creating the dataset
My configuration uses a zpool named
Navigate to Storage ⯈ Pools
Click on ⋮⯈ Add Dataset next to zpool
Enter
Click Save
The dataset is now mounted at
Moving exisiting configuration there
If you already had zerotier running, you now need to move the exisiting configuration onto the created dataset:
Create the start script
The start script will run at boot time to mount the dataset at the right position (I chose not to modify the default mountpoint of the dataset):
Run the start script at boot time
Navigate to Tasks ⯈ Init/Shutdown Scripts
Click ADD
Select Type:
Enter Script:
Select When:
Make sure Enabled is checked.
Click Save
Now its time to either reboot to test that the script is being run at boot time or you can simply run the start script by hand:
Verify and connect
To verify that the mounts are correct and zerotier is running:
If you did not have zerotier running before, you can now join a network:
Please let me know if this guide works for you or if you run into any issues.
Thats all,
Techlex
I played with a new FreeNAS setup yesterday and also ran into the issue described already various times in these forums: After a reboot, the joined networks are lost, and the ID of the zerotier client changes.
Why does that happen?
Zerotier stores its runtime data in the directory
/var/db/zerotier-one
. The changes in this directory are lost after reboot, as /var
is mounted as tmpfs:Code:
tmpfs on /var (tmpfs, local)
The steps needed to solve this are these:
- Create a dataset that will hold the zerotier runtime data
- Make a nullfs-mount to the runtime directory at boot time
- Restart the zerotier daemon after the nullfs-mount
Preparations
If you already have zerotier running on your FreeNAS Box, make sure to stop the daemon, it will not like with its data being juggled around:
Code:
service zerotier stop
Navigate to System ⯈ Tunables
Remove the
zerotier_enable
rc.conf entry if you already have it. This will be set by our start script, as zerotier might start before the mountpoint is available, making zerotier create new keys at each boot. This is prevented by only enabling the service after the mountpoint is available.Creating the dataset
My configuration uses a zpool named
zpool
. Make sure to adapt this to your instance.Navigate to Storage ⯈ Pools
Click on ⋮⯈ Add Dataset next to zpool
Enter
zerotier
as name. All other options can usually be inherited.Click Save
The dataset is now mounted at
/mnt/zpool/zerotier
Moving exisiting configuration there
If you already had zerotier running, you now need to move the exisiting configuration onto the created dataset:
Code:
mv /var/db/zerotier-one/* /mnt/zpool/zerotier/
Create the start script
The start script will run at boot time to mount the dataset at the right position (I chose not to modify the default mountpoint of the dataset):
Code:
cat >/mnt/zpool/zerotier/start.sh <<EOF #!/bin/sh mkdir -p /var/db/zerotier-one /sbin/mount_nullfs /mnt/zpool/zerotier /var/db/zerotier-one sysrc zerotier_enable=YES /usr/sbin/service zerotier restart EOF chmod +x /mnt/zpool/zerotier/start.sh
Run the start script at boot time
Navigate to Tasks ⯈ Init/Shutdown Scripts
Click ADD
Select Type:
Script
Enter Script:
/mnt/zpool/zerotier/start.sh
Select When:
Pre Init
Make sure Enabled is checked.
Click Save
Now its time to either reboot to test that the script is being run at boot time or you can simply run the start script by hand:
Code:
/mnt/zpool/zerotier/start.sh
Verify and connect
To verify that the mounts are correct and zerotier is running:
Code:
mount |grep zerotier # zpool/zerotier on /mnt/zpool/zerotier (zfs, local, nfsv4acls) # /mnt/zpool/zerotier on /var/db/zerotier-one (nullfs, local) zerotier-cli info # 200 info 00XXXXXXXX 1.2.12 ONLINE
If you did not have zerotier running before, you can now join a network:
Code:
zerotier-cli join #network
Please let me know if this guide works for you or if you run into any issues.
Thats all,
Techlex
Last edited: