What's new

Optimizing Samba

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Oracle

Regular Contributor
May I ask for some advice about the Samba server footprint? I'm looking to streamline it, if possible. It takes quite a lot of RAM and CPU time - more than anything else I have on the router now.

I like the option to set permissions and manage users via the webUI but the implementation is a bit clumsy. It looks like I can only manage the first level of directories on a drive. Maybe if I could be more specific, the server will read less content.

P. S. I've already read several posts advising not to use the router for file sharing / NAS because:
1) the hardware is insufficient / underpowered / not fit for purpose, so performance will be poor;
2) data corruption can occur.

I've attached an SSD drive to my AC86U because I wanted to run extended features by installing Entware and SSD is better than a USB pen drive. I also prefer it to a HDD, because it makes no noise.
Now that there's so much free space, why not use it? I'm very happy with the speeds (80 MB/s sustained write, ~90 MB/s read). If I could make the Samba server a little leaner - great, otherwise it's still good enough for me for small local needs.
 
Last edited:
You can modify Samba as you see fit using custom config files. Sharing specific directories won't have any effect on performance as directories are only read when requested by the client.
 
It takes quite a lot of RAM
This is normal, this is disk buffering done by the OS.

and CPU time
The bottleneck is the CPU rather than the disk, so once again this is normal. Lower CPU usage would mean lower throughput.

This is simply a limitation of what a router CPU can do. There isn't anything left to optimize.
 
That was fast. :)

What is it that "eats" the RAM? I hope it's not caching the files.
Does the number of folders / subfolders / files affect the load?
E.g., 1 shared folder with 100 files <> 2 shared folders with 50 files each <> 1 shared folder with 50 files?
Any impact of how many folders on first level on the drive?
I cannot make any 1st level folder not appear on the Samba list, visible to the clients, even if no R/W permissions given (the folder is visible, its content isn't).

I find this absolutely fascinating - how can certain features with no graphic interface consume so much resources on the host.
 
What is it that "eats" the RAM? I hope it's not caching the files.
Nothing "eats" RAM. Unused RAM is used to cache disk blocks that are read or written. This is a fundamental design of Linux/Unix memory management and not something that Samba in particular is doing.

Does the number of folders / subfolders / files affect the load?
No.

I cannot make any 1st level folder not appear on the Samba list, visible to the clients, even if no R/W permissions given (the folder is visible, its content isn't).
Asus' Samba implementation is very "dumbed down" as it designed for non-technical people. To make one of the root folders not be visible you'd have to create a smb.postconf script that inserts browseable = no into the Samba config file at the appropriate point.
 
Thanks. Hiding unwanted folders worked right away.
(I was mentally prepared to jump through hoops.)
Performance completely unchanged. :)

For anyone else interested in hiding a folder on their Samba shares:
1. Create / edit the smb.postconf file
nano /jffs/scripts/smb.postconf

2. Paste this inside
Bash:
#!/bin/sh
CONFIG=$1
source /usr/sbin/helper.sh

#logger -t smb.postconf "Overriding smb.conf."

# Hide folder from network
pc_insert "[Name_of_your_folder_here" "browseable = no" $CONFIG

3. Make it executable
chmod +x /jffs/scripts/smb.postconf

4. Restart Samba or reboot router, whichever makes you happy.
 
Note taken.
I did try the simple search and results were very off topic.

Now I'm wondering - am I actually degrading performance by allocating swap?
If the router sees the swap as available memory and decides to use it for cache, it goes to the same attached drive it's reading / writing files to. So now file access operations have to compete with memory swap operations, saturating the same USB interface.
 
If the router sees the swap as available memory and decides to use it for cache...
No, that never happens. Linux knows the difference between real memory and virtual memory. Using disk to cache disk would be madness.
 

Similar threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top