Mounting a SMB share for plugins persistently

Janus Ng

Explorer
Joined
Apr 10, 2016
Messages
63
I have just cloned my FreeNAS 11.1-U5 to a Synology NAS to free up space for other usage.

I share those files as a SMB share from the Synology NAS.

I would like to mount the SMB share in FreeNAS and put them into the storages for the jails.

Here is what I have done:
  • Put the SMB credential and related settings into /conf/base/etc/nsmb.conf.
  • Create a directory /net/synology
  • Create a script like:
Code:
mount_smbfs -N -E UTF-8:UTF-8 -I 192.168.0.100 //freenas@synology/data /net/synology

  • Add a post-init task to running the above script
  • Add the mount point to the jails

Unfortunately, I have found that a post-init task is too late. The jails have already started with the storage assigned before the task completes; hence, the jail storages fail to mount.
I have tried a pre-init task instead but it is too early. The mount point was not there yet.

Please enlighten me on how to accomplish it.

Thank you!
 
Last edited:

Janus Ng

Explorer
Joined
Apr 10, 2016
Messages
63
No, I still cannot mange to fix it. I have to change the settings of each shared drive in Jails/Storage of the WebUI every time the NAS starts, :(
 

Janus Ng

Explorer
Joined
Apr 10, 2016
Messages
63
I have tried to mount the SMB share by autofs as illustrated by @s25a on another thread in the forums.
https://forums.freenas.org/index.php?threads/freenas-as-automount-client.44356/

The auto mount was succeeded if I ssh to the server and ls to the directory. I saw the shared folders and files.

However, it seems the jails start earlier than the autofs does. The storages shared to jails were not mounted. I have to mount them again in the WebUI. :(
 
Last edited:

Janus Ng

Explorer
Joined
Apr 10, 2016
Messages
63
Update: shared storages on autofs mounted paths are unmounted from the jails after awhile of idle.
Autofs is not the solution even it can be done before the jails start.
 
Last edited:

Janus Ng

Explorer
Joined
Apr 10, 2016
Messages
63
Update:

I have revisited this issue and worked around the issue that smb_mount is not ready while a Post Init Task calls it.

  1. Changed all the Auto-start value from true to false on all the iocage jails that depends on the smb_mount
  2. Created a shell script A that mounts all the required smb_mount points. This script has to be run as root with authentication values and other required values populated in file /root/.nsmbrc.
  3. Created a shell script B that starts all the depended jails one by one. Similar to script A, it has to be run as root as well
  4. Created yet another shell script C that it touches a file D in /etc as a flag and call the script A and B above if the flag file D does not exist. As the directory /etc is recreated on each reboot, script C calls script A and B only once on each reboot.
  5. Created a Cron Job in Tasks Tab of the Web UI. It runs every minutes with all 5 schedule locations are filled with stars.
I have finally had a peace of mind now. In the event of unscheduled restart, all the jails are likely functional after the FreeNAS rebooted. :cool:
 
Top