Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[HOWTO] Customize SMB.conf
I dislike that a shared folder (“Backup” in my case) is added to the SMB.conf when I only want it to be available as a NFS share.  Windows 10 doesn't want to mount a NFS location if the same location is a SMB share.  After a lot of research and trial and error I came up with the below solution.  It's the accumulation of information from multiple different sources (all notated) and modified to fit my needs.  I thought it might be helpful to have it together in one thread.  Please feel free to ask questions.

Code to force the META startup to run in the backgroup: MrPete
I had a heck of a time finding the META module.  Thanks goes to outkastm for it’s development.  META allows you to create startup and/or shutdown scripts for your NAS.

First, I installed the META module.  Be sure to enable it.

Next, I loaded my existing smb.conf.

vi /var/run/smb.conf

I copied it’s contents to my favorite editor and removed the offending block - [Backup] in my case.

Now I needed someplace to keep my new modified SMB configuration file, so I created a directory under modules and named it SMB

mkdir /raid/data/module/SMB

I then created what would be my smb.conf template

vi /raid/data/module/SMB/

I pasted the modified smb.conf contents into the new files and closed the file after saving the changes.

Next we need to create the script that will actually replace the existing smb.conf with our new smb.conf everytime the NAS is booted.

vi /raid/data/module/META/system/etc/startup/

This file will contain the following code:

# Thanks to MrPete for the base code

echo "Starting SMBfix in background"


# Thecus system startup gives this script an argument (always "start"). I use that as a flag to know if I need to wait for smbd to start before editing anything.
# Here I declare a shell function to do all the work. Once it is declared, I will run it in the background down below.
# Then (once the background task is running) we immediately exit this script so the startup can continue.


   if [ $smbargs -gt 0 ]

       ((isleep = 0))
       echo "Waiting for Samba up to 100 sec" >>/raid/module/META/system/etc/startup.log
       while ! ps | grep -v grep | grep smbd &>/dev/null ; do
           sleep 1
           if [ $isleep -gt 100 ]
       echo "Took $isleep seconds for Samba to start" >>/raid/module/META/system/etc/startup.log

# make sure everything is quiet
   sleep 3

# replace existing smb.conf with mine
   cp /raid/data/module/SMB/ /var/run/smb.conf

# restart samba so it loads the new conf

   killall smbd
   killall nmbd

   /opt/samba/sbin/smbd -D
   /opt/samba/sbin/nmbd -D

   date >>/raid/module/META/system/etc/startup.log
   echo "SMBfix done" >>/raid/module/META/system/etc/startup.log

 SMBfixbg &

exit 0

Save and close the file and then make it executable

chmod +x

You can manually call the script to make sure it actually replaces the conf file.

bash  /raid/data/module/META/system/etc/startup/

Assuming the existing conf now mirrors the custom conf, you can reboot to ensure META does it's job.

This is a great thread on why all of this is necessary: Linky

META release thread: META  Direct META Download: Here

Another thread that provided some additional information: Linky

My system specs: N5550 with OS5 and firmware

Search Tags: Meta Module, SMB, Samba, smb.conf, smb.cfg, shared folder, startup script

Forum Jump:

Users browsing this thread: 1 Guest(s)