You will need:
- Router with USB port;
- OpenWRT or LEDE (recommended) firmware;
- USB stick or USB hard drive.
opkg update
opkg install kmod-usb-ohci kmod-usb2 usbutils kmod-usb-storage kmod-fs-ext4 block-mount
reboot
dmesg | grep sd
Output example:
[ 12.614343] sd 0:0:0:0: [sda] 61341696 512-byte logical blocks: (31.4 GB/29.3 GiB)
[ 12.626964] sd 0:0:0:0: [sda] Write Protect is off
[ 12.631918] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[ 12.643894] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 12.673730] sda: sda1
[ 12.682703] sd 0:0:0:0: [sda] Attached SCSI removable disk
block detect >> /etc/config/fstab
Change target to '/mnt/usb/' and enable automount. Example:
config 'mount'
option target '/mnt/usb/'
option uuid '<your device uuid>'
option enabled '1'
opkg update
opkg install vsftpd
mkdir -p /mnt/usb/ftp/
chown ftp /mnt/usb/ftp
passwd ftp
Enter any password you like.
Change /home/ftp to /mnt/usb/ftp.
Example:
ftp:x:55:55:ftp:/mnt/usb/ftp:/bin/false
Example:
background=YES
listen=YES
anonymous_enable=NO
local_root=/mnt/usb/ftp/
local_enable=YES
write_enable=YES
local_umask=022
chroot_local_user=YES
user_sub_token=$USER
allow_writeable_chroot=YES
check_shell=NO
port_enable=YES
pasv_enable=YES
pasv_address=<your static ip>
pasv_min_port=32000
pasv_max_port=32127
session_support=NO
/etc/init.d/vsftpd start
/etc/init.d/vsftpd enable
Example:
config rule
option name Allow-FTP
option target ACCEPT
option src wan
option proto tcp
option dest_port 21
option dest_ip <router local ip>
config redirect
option name Forward-FTP
option src wan
option dest_ip <router local ip>
option dest_port 21
option proto tcp
option src_dport <any external port you like>
option target DNAT
option dest lan
config rule
option name Allow-FTP-Passive
option src wan
option target ACCEPT
option dest_port 32000:32127
option dest_ip <router local ip>
option proto tcp
config redirect
option name Forward-FTP-Passive
option src wan
option dest_ip <router local ip>
option proto tcp
option src_dport 32000:32137
option target DNAT
option dest lan
Reboot device after setup (with reboot command).
Now you ready to test it.
For local network just use:
ip: <local router ip>
port: 21
user: ftp
pass: <your password>
For worldwide access:
ip: <your external static ip>
port: <external port>
user: ftp
pass: <your password>
opkg update
opkg install hd-idle
config 'hd-idle'
option 'disk' 'sda'
option 'enabled' '1'
option 'idle_time_unit' 'minutes'
option 'idle_time_interval' '10'
Reboot device after setup (with reboot command).