Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:services:nas:ksmbd [2024/01/05 21:36] – [Example] heading shrink linusdocs:guide-user:services:nas:ksmbd [2024/12/11 13:48] – [Example] sppmaster
Line 1: Line 1:
 ====== ksmbd ====== ====== ksmbd ======
-[[https://www.kernel.org/doc/html/latest/filesystems/cifs/ksmbd.html|ksmbd]] in an in-kernel server for sharing files over network. It implements SMB3 protocol and can be used as a [[docs:guide-user:services:nas:samba|Samba]] alternative.+[[https://docs.kernel.org/next/filesystems/smb/ksmbd.html|KSMBD]] is a server which implements SMB3 protocol in kernel space for sharing files over your network. It can be used as a [[:docs:guide-user:services:nas:cifs.server|Samba]] alternative
 + 
 +===== Installation ===== 
 + 
 +To use ksmbd with [[docs:guide-user:luci:start|LuCI]] install ''luci-app-ksmbd'' which will automatically install the server and dependencies. To use ksmbd only on the command line install ''ksmbd-server'' and ''ksmbd-tools''
 + 
 +If you are sharing a USB or eSATA drive make sure you also install the drivers and filesystem outlined on the Samba [[:docs:guide-user:services:nas:cifs.server#prerequisites]] page.
  
-You can install **ksmbd** on your system by first installing the ''ksmbd-server'' package. 
 ===== Configuration ===== ===== Configuration =====
-The UCI configuration file is located at ''/etc/config/ksmbd''. It can be edited using [[docs:guide-user:luci:start|LuCI]] after installing ''luci-app-ksmbd'' package. 
  
-Some options are hardcoded in the ''/etc/ksmbd/smb.conf.template''.+In LuCI, go to Services -> Network Shares. Here you can assign the interface, name the shares, and path to the drive folder, e.g. /mnt/sda1. 
 + 
 +For command line, the UCI configuration file is located at ''/etc/config/ksmbd''Some options are hardcoded in the ''/etc/ksmbd/ksmb.conf.template''.
  
 ==== Example ==== ==== Example ====
  
-Assume you have [[docs:guide-user:storage:fstab|configured two block devices]] for use on your NAS: an SSD on ''/mnt/sda1'' and a harddrive on ''/mnt/sdb1'' (these are standard OpenWrt mounting points). These can be using for example the ext4 filesystem.+This example assumes you have [[docs:guide-user:storage:fstab|block device]] attached on ''/mnt/sda1'' (typical Linux/OpenWrt mount points).\\ 
 +Multiple devices and shares may be added by providing a ''config share'' section with a name and mount location for each.
  
-In this example we will access the NAS storage anonymously using the ''nobody/nogroup'' user, so we first assign ownership for all files and directories at these mounting points to that user:+To access storage anonymously over the LAN using the ''nobody/nogroup'' user, first assign ownership for all files and directories at these mounting points to that user:
  
 <code> <code>
-chown -R nobody:nogroup /mnt/sda1 /mnt/sdb1+chown -R nobody:nogroup /mnt/sda1
 </code> </code>
  
-Then we can configure our shares in ''/etc/config/ksmbd'' like this:+To access a shared storage over the LAN using a **username** and **password** you have to use ''ksmbd.adduser'' from SSH. A ''/etc/ksmbd/ksmbdpwd.db'' file is created. 
 + 
 +<code> 
 +root@OpenWrt:~# ksmbd.adduser --help 
 +Usage: ksmbd.adduser [-v] [-P PWDDB] [-c CONF] [-a | -u | -d] [-p PWD] USER 
 + 
 +If neither `-a', `-u', nor `-d' is given, either add or update USER. 
 +USER must be UTF-8 and [1, 48) bytes. 
 +USER cannot contain colon (`:'). 
 + 
 +  -a, --add             add USER to user database 
 +  -u, --update          update USER in user database 
 +  -d, --delete          delete USER from user database 
 +  -p, --password=PWD    use PWD as user password instead of prompting; 
 +                        PWD must be UTF-8 and [0, 129) bytes 
 +  -P, --pwddb=PWDDB     use PWDDB as user database instead of 
 +                        `/etc/ksmbd/ksmbdpwd.db' 
 +  -C, --config=CONF     use CONF as configuration file instead of 
 +                        `/etc/ksmbd/ksmbd.conf' 
 +  -v, --verbose         be verbose 
 +  -V, --version         output version information and exit 
 +  -h, --help            display this help and exit 
 + 
 +See ksmbd.adduser(8) for more details. 
 +</code> 
 + 
 +Configure shares in LuCI → Services → Network Shares or by editing ''/etc/config/ksmbd'':
  
 <code> <code>
 config globals config globals
  option workgroup 'WORKGROUP'  option workgroup 'WORKGROUP'
- option description 'Ksmbd on My-Device'+ option description 'Ksmbd on OpenWrt'
  option interface 'lan'  option interface 'lan'
  
Line 33: Line 66:
  option create_mask '0666'  option create_mask '0666'
  option dir_mask '0777'  option dir_mask '0777'
 +</code>
  
-config share +On devices with sufficient RAM (typically >256MB) performance can be improved, increase or comment out the preset buffer limits in LuCI -> Services -> Network Shares -> Edit Template. Save and apply: \\ 
- option name 'harddisk' +As of this commit https://github.com/openwrt/packages/pull/25519 the below values are adjusted automatically (no need to change anything). This is valid for devices running OpenWrt main snapshot builds. \\ 
- option path '/mnt/sdb1' +For versions below 24.10 you have to manually edit the template and adjust the values accordingly.  
- option read_only 'no' +<code> 
- option guest_ok 'yes' + #smb2 max read = 512K 
- option create_mask '0666' + #smb2 max write = 512K 
- option dir_mask '0777'+ #smb2 max trans = 512K
 </code> </code>
 +
 ===== Global section ===== ===== Global section =====
 The ''globals'' section contains share-independent options. The ''globals'' section contains share-independent options.
  • Last modified: 2024/12/11 13:53
  • by sppmaster