A complete guide to OpenWrt router firmware installation and NAS function configuration
preface
OpenWrt as a powerful open-source router firmware that not only provides all the features of traditional routers, but also extends advanced functions such as NAS and smart home control with rich plugins. This article will detail the installation process of OpenWrt firmware and how to configure it as a powerful home NAS server.
1. Preparations
1.1 Hardware Requirements
- routers that support OpenWrt (mid-to-high-end models from ASUS, Netgear and other brands are recommended)
- at least 128MB of flash space
- at least 64MB of memory
- USB 2.0/3.0 interface (for external storage devices)
1.2 Software Tool
- TFTP client tools
- WinSCP or FileZilla (for file transfers)
- router management interface to access tools
2. OpenWrt firmware download
2.1 Official firmware acquisition
visit the official OpenWrt website and download the latest stable firmware version:
2.2 Firmware Version Selection
- Universal Firmware : Fits most routers with full functionality
- Streamlined firmware : Smaller size for devices with limited flash memory
- Dev Firmware : Contains the latest features, but may have stability issues
2.3 Checking Firmware Integrity
after the download is complete, be sure to verify the firmware's MD5 or SHA256 checksum:
md5sum openwrt-22.03.5-generic-initramfs-combined-efi.img.gz sha256sum openwrt-22.03.5-generic-initramfs-combined-efi.img.gz 3. Firmware installation steps
3.1 TFTP Installation Method
- restore the router to factory settings
- set the router IP to 192.168.1.1
- running a TFTP client:
tftp -i 192.168.1.1 put openwrt-22.03.5-generic-initramfs-combined-efi.img.gz - wait for the transfer to complete and the router will automatically restart
3.2 How to install the web interface
- log in to the router management interface
- go to System → Firmware Upgrade
- select the downloaded firmware file
- click "Upload and install"
3.3 Post-Installation Configuration
- wait for the router reboot to complete
- access the 192.168.1.1 through a browser
- set up admin passwords and network configuration
4. NAS function configuration
4.1 Install the necessary software packages
log in to the OpenWrt command line interface and execute the following commands:
opkg update opkg install luci-app-samba4 luci-app-usbmount kmod-fs-ext4 4.2 Configuring Samba File Sharing
- go to System → Sharing
- click "Add share"
- configure a shared directory:
- Share name: NAS-share
- path: /mnt/sda1/share
- access: Read and write
- Allowed Users: everyone
4.3 USB Storage Device Configuration
- connect a USB hard drive to the router
- Check Device Identification:
fdisk -l - Create a file system:
mkfs.ext4 /dev/sda1 - mount configuration:
echo '/dev/sda1 /mnt/sda1 ext4 defaults 0 0' >> /etc/fstab mkdir -p /mnt/sda1/share mount -a
5. Advanced function configuration
5.1 BT Download Function
opkg install transmission-daemon luci-app-transmission configure Transmission:
- Enable service:
/etc/init.d/transmission-daemon enable - Restart Service:
/etc/init.d/transmission-daemon restart - access web interface: http://192.168.1.1:9091
5.2 Media Server
opkg install minidlna configure MiniDLNA:
- Edit Configuration File:
vi /etc/config/minidlna - set the media directory:
media_dir=/mnt/sda1/media - Enable the service:
/etc/init.d/minidlna enable
5.3 Automatic backup
opkg install rsync Create a backup script:
#!/bin/sh rsync -avz /mnt/sda1/config/ /mnt/sda1/backup/config/ 6. Safety configuration
6.1 Firewall Settings
- go to Network → Firewall
- Add a new region: NAS
- configure port forwarding rules
- restrict access to IP addresses
6.2 User Rights Management
- Create a dedicated user:
useradd nasuser - Set password:
passwd nasuser - configure Samba user:
pdbedit -a nasuser
6.3 Regular Security Update
opkg update opkg upgrade 7. Performance optimization
7.1 System Tuning
-
Adjust kernel parameters:
echo 'vm.swappiness=10' >> /etc/sysctl.conf echo 'net.core.wmem_max=134217728' >> /etc/sysctl.conf sysctl -p -
Optimized File System:
tune2fs -o journal_data_writeback /dev/sda1
7.2 Network Optimization
-
Hardware acceleration enabled:
echo 'options ath10k_core ant_div_lna_div=1' > /etc/modprobe.d/ath10k.conf -
adjust MTU value:
ifconfig eth0 mtu 9000
8. Troubleshooting
8.1 FAQs
- USB device does not recognize : Check the power supply, try a different USB port
- unstable network connection: Check the firmware version and consider upgrading or downgrading
- Samba slow access : Adjust network parameters and check the health status of the hard drive
8.2 Log viewing
logread dmesg | tail 8.3 System Monitoring
Install monitoring tools:
opkg install htop lm-sensors sensors