Skip to content
This repository has been archived by the owner on Mar 17, 2018. It is now read-only.

USB Storage setup

James Doyle edited this page Dec 24, 2017 · 3 revisions

This part is firmware-depended and requires telnet or SSH access in most cases. The goal is to mount /opt folder to some ext2/ext3 partition on external USB drive, which will be automatically mounted on every boot, so make sure one or more ext2/ext3 partition is present on drive before installation.

Asuswrt-merlin firmware

There is simple way to do it, just plug in USB storage with one or more ext2/ext3-formatted partition, copy the contents of the entware-setup.sh to it or to the router, and then run:

chmod +x entware-setup.sh
entware-setup.sh

This script covers whole Entware installation, including USB storage setup, no additional steps is needed.

Asus stock firmware

It's related to any modern ASUS router with USB port: RT-N10U, RT-N13U, RT-N15U, RT-N16, RT-N56U, RT-N65U, RT-N66U, RT-AC66U and so on. All those routers uses firmware partially based on TomatoUSB code, so we may use a custom start/stop scripts to ignite external services from USB drive! USB partitions will be mounted by it's label, in this example ext2/ext3 partiton got MYPART label. Copy & past in console:

cat << EOF > /tmp/script_usbmount.tmp
if [ \$1 = "/tmp/mnt/MYPART" ]
then
ln -sf \$1 /tmp/opt
/opt/etc/init.d/rc.unslung start
fi
EOF
nvram set script_usbmount="`cat /tmp/script_usbmount.tmp`"

cat << EOF > /tmp/script_usbumount.tmp
if [ \$1 = "/tmp/mnt/MYPART" ]
then
/opt/etc/init.d/rc.unslung stop
fi
EOF
nvram set script_usbumount="`cat /tmp/script_usbumount.tmp`"

nvram commit 
reboot

Oleg's firmware

A first USB storage partition will be used in example. Copy & past to console:

mkdir -p /usr/local/sbin
cat << EOF > /usr/local/sbin/pre-shutdown
#! /bin/sh
/opt/etc/init.d/rc.unslung stop
sleep 10s
for i in `cat /proc/mounts | awk '$3 ~ /ext[23]/ {print($1)}'` ; do
  mount -oremount,ro $i
done
EOF
cat << EOF > /usr/local/sbin/post-mount
#! /bin/sh
/opt/etc/init.d/rc.unslung start
EOF
echo "/etc/fstab" >> /usr/local/.files
echo "/dev/discs/disc0/part1  /opt            ext3    rw,noatime      1       1" >> /etc/fstab
chmod +x /usr/local/sbin/*
flashfs save && flashfs commit && flashfs enable && reboot

More details is here.

Padavan's firmware

Just make sure Entware is enabled on USB Application > Common settings WebUI page. Details is here

TomatoUSB firmware

Example uses ext2/ext3 partiton with MYPART label. Enable following option on NAS > USB Support WebUI page:

[x] Core USB Support
[x] USB 2.0 Support
[x] USB Storage Support
[x] Ex2/Ext3 File Systems Support
[x] Automount

Place this text to Run after mounting box:

#!/bin/sh
/opt/etc/init.d/rc.unslung start

and this one to Run before unmounting box:

#!/bin/sh
/opt/etc/init.d/rc.unslung stop
sleep 15
for i in `cat /proc/mounts | awk '$3 ~ /ext[23]/ {print($1)}'` ; do
  mount -o remount,ro $i
done

and click Save button. Now go to Administration > Scripts > Init page, enter

echo "LABEL=MYPART /opt ext3 defaults 1 1" >> /etc/fstab

and click Save button. Reboot router and install Entware. Specify ext2 if you are using that.

DD-WRT firmware

Go to Services > USB WebUI page and enable following options:

[x] Core USB Support
[x] USB 2.0 Support
[x] USB Storage Support
[x] Automatic Drive Mount

Choose /opt in Disk mount point drop down list and click Save button. Reboot router and install Entware. Details is here.