How to make Samba tweaks reboot-proof? (smb.conf)

Questions and mods regarding system management may go here
Forum rules
Please note the disclaimer before modifying your Synology Product.
User avatar
Sakkerju
Sharp
Sharp
Posts: 178
Joined: Wed Jan 20, 2010 12:35 pm
Location: Netherlands, Europe

How to make Samba tweaks reboot-proof? (smb.conf)

Postby Sakkerju » Mon Apr 19, 2010 10:00 am

I use Samba shares to access my Synology DS209+II from Windows (7) environment.
For this, I prefer to have direct access to 'volume1' to view whole '/volume1' as a Samba shared folder
(Also possible to have it at / level, so you can acces the system partition too)

I configure this by manually adding an additional share in the Samba config file and restart Samba deamon via a Telnet session.
/usr/syno/etc/smb.conf
This works really great! I have a single share to access all my data files/folders (nice for moving files within folders via Windows)

However, the setting I make are lost after a reboot from the Synology.
It defaults back and restores the original setting in the smb.conf

- Can I make this more permanent (reboot-proof)?
- Should I update another .conf file somewhere?
Synology DS209+II - DSM 4.1 - WD Red 3TB (RAID1) *** Linksys WRT320N 1Gb *** Logitech Media Server 7.7.2
Squeezeboxes "Touch / Radio / Controller / Android App" *** WD TV Live Media Player *** UPC Horizon mediabox
jarvis
Experienced
Experienced
Posts: 107
Joined: Sun May 23, 2010 8:52 pm
Contact:

Re: How to make Samba tweaks reboot-proof? (smb.conf)

Postby jarvis » Fri May 28, 2010 7:13 am

+1 for this

Originally posted in File Sharing forum, so mods feel free to move my post here:
http://forum.synology.com/enu/viewtopic.php?f=111&t=24788
...defiantly mixing and matching drive manufacturers to avoid getting 3 duff drives that fail in the same month...
DS410: Seagate Barracuda ST31000528AS, Hitachi Deckstar HDS721010CLA332, Samsung SpinPoint HD103SJ.
All 1TB capacity, 32Mb buffer in RAID5
Enjoying music streamed to my Linn Majik DS
User avatar
Sakkerju
Sharp
Sharp
Posts: 178
Joined: Wed Jan 20, 2010 12:35 pm
Location: Netherlands, Europe

Re: How to make Samba tweaks reboot-proof? (smb.conf)

Postby Sakkerju » Tue Jun 01, 2010 12:13 pm

There might not be just a simple way to solve this :roll:

I think this workaround is a way to solve this matter.
simply saving the smb.conf at shutdown and restoring it at startup...
Or maybe 'restarting' SMB AFTER startup....

/usr/local/etc/rc.d/S80samba.sh stop|start|restart

Then, modify original script i've sent you like:

Code: Select all

# ================== cut here =====
#!/bin/sh

# stop samba
/usr/local/etc/rc.d/S80samba.sh stop

# backup default smb.conf
cp /usr/syno/etc/smb.conf /usr/syno/etc/backup/smb.conf

# copy backup config file
cp /usr/syno/etc/bacup/smb.conf  /usr/syno/etc/smb.conf

# restart samba
/usr/local/etc/rc.d/S80samba.sh start
# ========================= cut here ==========


Pay attention, that you need to create a directory BACKUP in /usr/syno/etc/
Synology DS209+II - DSM 4.1 - WD Red 3TB (RAID1) *** Linksys WRT320N 1Gb *** Logitech Media Server 7.7.2
Squeezeboxes "Touch / Radio / Controller / Android App" *** WD TV Live Media Player *** UPC Horizon mediabox
jarvis
Experienced
Experienced
Posts: 107
Joined: Sun May 23, 2010 8:52 pm
Contact:

Re: How to make Samba tweaks reboot-proof? (smb.conf)

Postby jarvis » Tue Jun 01, 2010 3:52 pm

Sakkerju wrote:I think this workaround is a way to solve this matter.
simply saving the smb.conf at shutdown and restoring it at startup...
Or maybe 'restarting' SMB AFTER startup....


I put my own script into the crontab file (nothing to do with this topic) but it didn't run at the appointed date/time. Checking back, the crontab file has also been reset after reboot - now the only lines are the ones added by DSM for time sync and shutdown! :lol:

So your tip might work if I run it manually every day, but I can't schedule it. Of course if I disable scheduled shutdown it would be fine probably.
...defiantly mixing and matching drive manufacturers to avoid getting 3 duff drives that fail in the same month...
DS410: Seagate Barracuda ST31000528AS, Hitachi Deckstar HDS721010CLA332, Samsung SpinPoint HD103SJ.
All 1TB capacity, 32Mb buffer in RAID5
Enjoying music streamed to my Linn Majik DS
User avatar
Sakkerju
Sharp
Sharp
Posts: 178
Joined: Wed Jan 20, 2010 12:35 pm
Location: Netherlands, Europe

Re: How to make Samba tweaks reboot-proof? (smb.conf)

Postby Sakkerju » Tue Jun 01, 2010 10:40 pm

jarvis wrote:So your tip might work if I run it manually every day, but I can't schedule it. Of course if I disable scheduled shutdown it would be fine probably.


I was thinking of creating a high Sxx script to start during startup, having it restore the pre-boot smb.conf and restart Samba.
Not tried it yet, but must be possible when linked to rc.d to autostart....
Synology DS209+II - DSM 4.1 - WD Red 3TB (RAID1) *** Linksys WRT320N 1Gb *** Logitech Media Server 7.7.2
Squeezeboxes "Touch / Radio / Controller / Android App" *** WD TV Live Media Player *** UPC Horizon mediabox
n_brown
I'm New!
I'm New!
Posts: 2
Joined: Mon Aug 16, 2010 8:31 pm

Re: How to make Samba tweaks reboot-proof? (smb.conf)

Postby n_brown » Mon Aug 16, 2010 8:35 pm

My approach to fixing this was to make the smb.conf file immutable. I had to add the 'chattr' program with ipkg (part of the e2fsprogs package), and then just set the smb.conf file as immutable with 'chattr +i /usr/syno/etc/smb.conf'.

-Nick
hshah
Student
Student
Posts: 77
Joined: Thu Aug 22, 2013 7:26 pm

Re: How to make Samba tweaks reboot-proof? (smb.conf)

Postby hshah » Tue Mar 29, 2016 2:56 am

Anyone know a decent way with DSM 6.0?
User avatar
Sakkerju
Sharp
Sharp
Posts: 178
Joined: Wed Jan 20, 2010 12:35 pm
Location: Netherlands, Europe

Re: How to make Samba tweaks reboot-proof? (smb.conf)

Postby Sakkerju » Fri Apr 01, 2016 7:20 pm

hshah wrote:Anyone know a decent way with DSM 6.0?


It is reboot proof in my situation.
I made some manual manual tweaks in the file below and these stay after reboot...
Logon with user account; sudo su (dsm6)
vi /etc/samba/smb.conf
Synology DS209+II - DSM 4.1 - WD Red 3TB (RAID1) *** Linksys WRT320N 1Gb *** Logitech Media Server 7.7.2
Squeezeboxes "Touch / Radio / Controller / Android App" *** WD TV Live Media Player *** UPC Horizon mediabox
Rosen32
Trainee
Trainee
Posts: 18
Joined: Thu Mar 10, 2016 8:10 pm

Re: How to make Samba tweaks reboot-proof? (smb.conf)

Postby Rosen32 » Wed Apr 13, 2016 7:49 am

I managed to create this "volume1"-share and got it to work, and now see all subfolders in that volume (that makes all files, I guess).

However, does anyone know how i can hide some of the folders in the share, ie all the directories containing the "@", for a specific user that connects to the "volume1"-share?
Since all foldera are seen when connecting to "volume1" with SMB in OS X El Capitan, I would like to know if there is any way of only see the shared folders at "volume1" to use this SMB-share to get only one connected drive on my desktop – without the risk of editing the other files on the drive.
User avatar
Sakkerju
Sharp
Sharp
Posts: 178
Joined: Wed Jan 20, 2010 12:35 pm
Location: Netherlands, Europe

Re: How to make Samba tweaks reboot-proof? (smb.conf)

Postby Sakkerju » Wed Apr 13, 2016 8:53 am

This works for me to hide folders on (DSM6):

1. Logon with priveliged user account;
2. sudo su to get root privileges
3. vi /etc/samba/smb.conf
4. to hide folders, just add them like this in the specific share part:
hide files = /@maillog/
or try this for all
hide files = /@*/
5. :wq
6. /usr/syno/etc/rc.sysv/S80samba.sh restart
Synology DS209+II - DSM 4.1 - WD Red 3TB (RAID1) *** Linksys WRT320N 1Gb *** Logitech Media Server 7.7.2
Squeezeboxes "Touch / Radio / Controller / Android App" *** WD TV Live Media Player *** UPC Horizon mediabox
Rosen32
Trainee
Trainee
Posts: 18
Joined: Thu Mar 10, 2016 8:10 pm

Re: How to make Samba tweaks reboot-proof? (smb.conf)

Postby Rosen32 » Wed Apr 13, 2016 5:38 pm

Sakkerju wrote:This works for me to hide folders on (DSM6):

1. Logon with priveliged user account;
2. sudo su to get root privileges
3. vi /etc/samba/smb.conf
4. to hide folders, just add them like this in the specific share part:
hide files = /@maillog/
or try this for all
hide files = /@*/
5. :wq
6. /usr/syno/etc/rc.sysv/S80samba.sh restart


Thanks, works like a charm.
Do you also happen to know how to hide [all] files in the root?
User avatar
Sakkerju
Sharp
Sharp
Posts: 178
Joined: Wed Jan 20, 2010 12:35 pm
Location: Netherlands, Europe

Re: How to make Samba tweaks reboot-proof? (smb.conf)

Postby Sakkerju » Thu Apr 14, 2016 2:04 pm

Hiding the files in root is same trick, just add them specifically in smb.conf.
Or find a clever 'joker' to tackle more at once....

e.g. containing name 'quota' in the filename (not tested be should work):

hide files = /*quota*/
Synology DS209+II - DSM 4.1 - WD Red 3TB (RAID1) *** Linksys WRT320N 1Gb *** Logitech Media Server 7.7.2
Squeezeboxes "Touch / Radio / Controller / Android App" *** WD TV Live Media Player *** UPC Horizon mediabox
Rosen32
Trainee
Trainee
Posts: 18
Joined: Thu Mar 10, 2016 8:10 pm

Re: How to make Samba tweaks reboot-proof? (smb.conf)

Postby Rosen32 » Thu Apr 14, 2016 5:43 pm

Sakkerju wrote:Hiding the files in root is same trick, just add them specifically in smb.conf.
Or find a clever 'joker' to tackle more at once....

e.g. containing name 'quota' in the filename (not tested be should work):

hide files = /*quota*/


Thanks for your reply,
however, it seems like only one row could be added, when using only hide files = /*quota*/ or only hide files = /@*/, the configuration works.
If i add both, each in a separate row as in the other shares in the smb-file, it does not work, since both files and folders could be seen in the share.

Any ideas?
User avatar
Sakkerju
Sharp
Sharp
Posts: 178
Joined: Wed Jan 20, 2010 12:35 pm
Location: Netherlands, Europe

Re: How to make Samba tweaks reboot-proof? (smb.conf)

Postby Sakkerju » Thu Apr 14, 2016 7:05 pm

If you want to make it count for all shares, put it under this part of the smb.conf file:
[global]
hide files = /apps/

Not sure if this is the issue, but to combine in a single command:
hide files = /*quota*/@*/ etc... /

Thumbs up ;-)
Synology DS209+II - DSM 4.1 - WD Red 3TB (RAID1) *** Linksys WRT320N 1Gb *** Logitech Media Server 7.7.2
Squeezeboxes "Touch / Radio / Controller / Android App" *** WD TV Live Media Player *** UPC Horizon mediabox
Rosen32
Trainee
Trainee
Posts: 18
Joined: Thu Mar 10, 2016 8:10 pm

Re: How to make Samba tweaks reboot-proof? (smb.conf)

Postby Rosen32 » Thu Apr 14, 2016 7:47 pm

Sakkerju wrote:If you want to make it count for all shares, put it under this part of the smb.conf file:
[global]
hide files = /apps/

Not sure if this is the issue, but to combine in a single command:
hide files = /*quota*/@*/ etc... /

Thumbs up ;-)


You're the man!
Single line worked perfectly.

Return to “System Managment Mods”

Who is online

Users browsing this forum: Ge0kas and 3 guests