{"id":82,"date":"2020-09-17T15:06:15","date_gmt":"2020-09-17T20:06:15","guid":{"rendered":"https:\/\/sourceopen.com\/?p=82"},"modified":"2020-09-21T00:20:25","modified_gmt":"2020-09-21T05:20:25","slug":"how-to-fix-slow-samba-smbd-on-openbsd","status":"publish","type":"post","link":"https:\/\/sourceopen.com\/index.php\/how-to-fix-slow-samba-smbd-on-openbsd\/","title":{"rendered":"How to Fix Slow Samba smbd on OpenBSD"},"content":{"rendered":"\n<p>So I have been testing out a Samba file server on my OpenBSD 6.7 machine. Its <em>read <\/em>speed from the OpenBSD Samba server to a Windows 10  client was about 100MB\/sec, right where I would expect it with Gigabit Ethernet. <\/p>\n\n\n\n<p>However, the <em>write <\/em>speed was an abysmal 25 MB\/sec!  On my (much slower hardware) Linux Samba server I get about 100MB\/sec in both directions. But with OpenBSD the write is terrible by default. I thought perhaps it could just be Linux file caching and delayed writes were beating the more conservative OpenBSD.<\/p>\n\n\n\n<p>After some experimentation I found that doing two things helped the BSD machine get up to the level of the Linux machine.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">So how do you fix the slow data transfer with Samba running on OpenBSD? Like this:<\/h3>\n\n\n\n<p>First increase the buffers for OpenBSD:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># sysctl -w net.inet.divert.sendspace=262144\n\n# sysctl -w net.inet.divert.recvspace=262144\n\n# sysctl -w net.inet6.divert.sendspace=262144\n\n# sysctl -w net.inet6.divert.recvspace=262144<\/code><\/pre>\n\n\n\n<p>These changes to sysctl will not persist after a reboot. So once you are sure it is all working you can add them to  \/etc\/sysctl.conf by adding just the following lines to \/etc\/sysctl.conf<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>net.inet.divert.sendspace=262144\nnet.inet.divert.recvspace=262144\nnet.inet6.divert.sendspace=262144\nnet.inet6.divert.recvspace=262144<\/code><\/pre>\n\n\n\n<p>Next we adjust the buffers in \/etc\/samba\/smb.conf:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;global]\n\n#put right after global\nsocket options = SO_SNDBUF=262144 SO_RCVBUF=262144\n\n...\n#rest of file<\/code><\/pre>\n\n\n\n<p>Restart Samba:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># rcctl restart smbd<\/code><\/pre>\n\n\n\n<p>Try out your new faster Samba on OpenBSD!<\/p>\n\n\n\n<p>I experimented with smaller and larger values for these buffers. On my hardware these were the fastest values. YMMV; so perhaps test it out a little bigger or smaller. It&#8217;s probably best to keep these powers of two. It will, after all, affect EVERY Samba file transfer. So any improvement is a good thing!<\/p>\n\n\n\n<p>And that is how you fix slow write speeds on Samba smbd for OpenBSD.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I have been testing out a Samba file server on my OpenBSD 6.7 machine. Its read speed from the OpenBSD Samba server to a Windows 10 client was about 100MB\/sec, right where I would expect it with Gigabit Ethernet. &hellip; <a href=\"https:\/\/sourceopen.com\/index.php\/how-to-fix-slow-samba-smbd-on-openbsd\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[3,4,55,23,2,54,57,58,56,24],"_links":{"self":[{"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/posts\/82"}],"collection":[{"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/comments?post=82"}],"version-history":[{"count":2,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/posts\/82\/revisions"}],"predecessor-version":[{"id":84,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/posts\/82\/revisions\/84"}],"wp:attachment":[{"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/media?parent=82"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/categories?post=82"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/tags?post=82"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}