Samba on OpenWrt is useful when I want to share a mounted HDD, SSD, or flash drive with Windows, Linux, or macOS clients on the LAN. OpenWrt also offers ksmbd, a lower-resource SMBv3 kernel server with fewer features; this article follows the official luci-app-samba4 path.[26]
Prerequisites
The USB/eSATA drive must already have its driver, filesystem, and mount point. A common package set is:[26]
| |
In LuCI, mount the drive under System → Mount Points, enable the entry, click Save & Apply, and use Generate Config if needed. Record the mount point, for example /dev/sda1 becoming /mnt/sda1. The source recommends at least 128 MB RAM; lower-memory machines may need another 128–256 MB of swap.[26]
Install and create a basic share
- Install
luci-app-samba4; dependencies such assamba4-serverare installed automatically.[26] - Open Services → Network Shares in LuCI.[26]
- Start with these values:[26]
| Field | Example |
|---|---|
| Interface | lan |
| Workgroup | WORKGROUP |
| Enable Extra Tuning | enabled; disable it for Apple Time Machine |
| Shared Directories | click Add |
| Name | a share name |
| Path | /mnt/sda1 or the actual mount point |
| Browseable | enabled |
| Read-only | disabled when writes are needed |
| Force Root | only on a trusted LAN |
| Allowed users | optional when using accounts |
| Allow guests | enabled when accounts are not used |
| Create Mask | 0666 |
| Directory Mask | 0777 |
Click Save and Apply. A correctly configured share can then be read and written from the LAN; Windows, for example, can open \\192.168.1.1\\storage\\. I do not expose Samba to the Internet just for convenience.[26]
Use user accounts instead of guest access
When guest access is not appropriate:[26]
- Add a user entry to
/etc/passwdand/etc/group.[26] - Choose a UID/GID of at least 1000 to avoid reserved values.[26]
- Set a Samba password interactively with
smbpasswd -a username; do not put the password in an article or repository.[26] - Add the account to LuCI → Network Shares → Allowed users, then Save & Apply.[26]
Safe illustrative entries are:[26]
| |
Use chown and chmod for the required filesystem access. Unknown authentication names may be silently mapped to guest by default, so I check both filesystem permissions and Samba access rules.[26]
Advanced configuration outside UCI
After changing configuration files, restart Samba so /etc/samba/smb.conf is regenerated:[26]
| |
LuCI/UCI builds the result from /etc/config/samba and /etc/samba/smb.conf.template. If I genuinely need to manage smb.conf beyond UCI:[26]
| |
Add this to /etc/rc.local:[26]
| |
This makes startup and configuration my responsibility; later UCI changes can overwrite the file on boot.[26]
Apple Time Machine share
In Services → Network Shares, create a dedicated share with these important choices:[26]
- Interface
lan, WorkgroupWORKGROUP.[26] - Disable Enable Extra Tuning and Force synchronous I/o.[26]
- Enable Enable macOS compatible shares.[26]
- Disable Allow legacy (insecure) protocols/authentication; leave Disable netbios unchecked.[26]
- Shared directory: a name, a path such as
/mnt/sda1, Browseable enabled, Read-only disabled.[26] - Use Force Root only on a secure LAN; prefer a dedicated account.[26]
- Define Allow users and disable Allow guests.[26]
- Create Mask
0600, Directory Mask0700, Vfs objects disabled.[26] - Enable Apple Time-machine share; the GB limit may be blank or set.[26]
The source says to disable Enable Extra Tuning for current macOS versions and that an extra avahi service is not needed on OpenWrt.[26]
Check access and startup
If a share will not open, inspect /etc/samba/smb.conf.template, the filesystem driver, and the mount point. As a diagnostic, the source suggests changing security from user to share, restarting the daemons, and trying:[26]
- Windows Explorer:
\\router_ip[26] - Nautilus/Dolphin: press
<CTRL>+<L>and entersmb://router_ip/[26]
After installation, confirm the service under LuCI → System → Startup. From the command line:[26]
| |
If Windows does not show the share in Network, install wsdd2.[26]
Cannot write to a share
First check directory permissions and the account. The source lists this test, but 777 grants broad access, so I use it only for diagnosis on a trusted LAN and then narrow the permissions:[26]
| |
For an fstab mount, inspect the options, for example:[26]
| |
I do not keep umask=000 on a network with untrusted clients.[26]
International characters and LAN firewall
If names containing accented characters cannot be read or written:[26]
| |
Restart Samba afterwards. With slow NAT paths, the documentation includes a LAN conntrack bypass for SMB ports:[26]
| |
Remote access is not the default
The source also shows ACCEPT rules for SMB ports. I treat those as a special case on a controlled network; Samba/NAS should normally remain on the LAN or travel through a VPN. Do not expose 137–139/445 to the Internet without understanding update and authentication risks:[26]
| |
macOS discovery and reference performance
To support WINS-style discovery, edit /etc/samba/smb.conf.template through Services → Network Shares → Edit Template, inside [global]:[26]
| |
The WINS address can also be advertised through DHCP:[26]
| |
The source's reference numbers are not a universal benchmark:[26]
| Device/condition | Read | Write |
|---|---|---|
| WRT3200ACM, USB3 NTFS, 1Gb LAN, OpenWrt 23.05 | 100 MB/s | 110 MB/s |
| GL-MT6000, USB3 exFAT, 1Gb LAN, OpenWrt 24.10 | 85 MB/s | 115 MB/s |
| N100, USB3 exFAT, 1Gb LAN, OpenWrt 24.10 | 120 MB/s | 120 MB/s |
Troubleshooting checklist
- Does
ps auxshowsmbd -Dandnmbd -D?[26] - Did I create accounts and add them to Allowed users?[26]
- Did I run
service samba4 restartafter editing?[26] - Is the filesystem driver installed and is the partition mounted?[26]
- After unmounting, can I run
fsck.exfat /dev/sda1if appropriate?[26] - Does the firewall allow LAN clients to reach the service?[26]
Source
Original source: [Samba]1, published/updated 2026-08-18.[26]
Sources
[26] https://openwrt.org/docs/guide-user/services/nas/cifs.server — OpenWrt Wiki: Samba


Góp Ý / Bình Luận / Đánh giá