Setup File Sharing (SMB) on OpenWrt with Samba4

Why I write this guide?

Well, there are 2 guides for Samba4 and Samba3 on the OpenWrt Wiki. Each of the guide is missing a “small” piece of information which makes beginner confused.


More information on how to setup the storage on OpenWrt available here.

  • USB Disk (USB stick/ USB to SATA adapter)
opkg update
opkg install kmod-usb-storage
opkg install kmod-usb-storage-uas
opkg install usbutils
lsusb -t
  • Native SATA/NVMe Disk

Usually there is no need to install driver

2. Check if device is detected

ls -l /dev/sd* => if using USB stick or HDD/SSD with SATA to USB adapter
ls -l /dev/nvm* => if using NVMe
opkg install block-mount
block info

3. Create a partition on the disk

For this video/tutorial, I use fdisk

opkg install fdisk
fdisk /dev/nvme0n1 (Replace by your NVMe SSD disk name)
fdisk /dev/sda1 (Replace by your USB/SSD/HDD disk name)

  • d => Delete partition
  • n => New partition
  • w => Write change to disk

4. Create a file system in the partition

This guide is only for ext4 file system. If you wish to use a different file system, please see the document.

opkg install e2fsprogs
opkg install kmod-fs-ext4
mkfs.ext4 /dev/sda1      => if you are using USB Stick/HDD/SSD
mkfs.ext4 /dev/nvme0n1    => if you are using NVMe

5. Auto mount the partition

It is easier to mount the partition using LuCI. See my video for more information. If you wish to do it with CLI, here is the commands

block detect | uci import fstab

uci set fstab.@mount[-1].enabled='1'
uci commit fstab

uci set fstab.@global[0].check_fs='1'
uci commit fstab

6. Install Samba4

opkg update && opkg install luci-app-samba4

Afer that, configure it with the the Web-UI. The Samba4 service should be automatically restart. If it doesn’t work, you can use

/etc/init.d/samba restart

7. Configure Samba Users

The username is stored in /etc/passwd file. To modify it, use VI or Nano

vi /etc/passwd

After that, insert this example line to end of the file. It will create a new username with the below information:


Hint: Using the same username for Samba4 (OpenWrt) and Windows will cause some problems where you need to change some setting on Local Security Policy. If possible, please use a different username for Samba4 & Windows.

  • user in this example will be called ‘vantc’“ (this is the loginname you need to enter, when Windows pops up the authentication dialogue)
  • with the unique system ID ‘1000’
  • with the group id ‘65534’ (which is the group identifier for ‘nobody’= no special default group)
  • ‘/var’ just means the user will not need a special home folder on the system
  • ‘/bin/false’ means the user will not have a default shell program associated

smbpasswd -a vantc => Set password
service samba restart (Optional)

8.Troubleshoot – No Write Access

  • Modifying the permissions and owner of the folder

If you are using USB stick/ HDD/ SSD

chmod -R 777 /mnt/sda1
chown -R nobody /mnt/sda1

If you are using NVMe

chmod -R 777 /mnt/nvme0n1
chown -R nobody /mnt/nvme0n1

More info:

9. Fine-Tune & others

  • Since netfilter tracks every connection, it may improve throughput to disable conntrack for Samba connections if you use NAT.
  • Remote Access
    Doable, not recommended. You better setup Wireguard VPN to access the NAS locally.
  • Apple Discovery & Network Discovery

10. Enjoy your OpenWrt NAS

Have fun with your OpenWrt NAS.

If you enjoy my content, feel free to give it a like, leave a comment, subscribe to the channel, give me a Super Thanks or support me on Patreon. I will be happy regardless of the action!

Notify of
Newest Most Voted
Inline Feedbacks
View all comments
10 months ago

Lo Instales en WRT3200ACM, Necesito Instalar, Asterisk, Dockers, MariaDB.
SALUDOS, siempre sigo tus videos de enseñanza.

Harlow Bernard
4 months ago

We just wanted to take a moment to acknowledge all the hard work and effort you’ve been putting in lately. Keep up the amazing job, you’re doing great!