This tutorial will document steps you need to take to add USB storage to your OpenWrt router. These steps are tested on OpenWrt 21.02 in 2022.
These steps were tested on a BT HomeHub 5 which was modified to run OpenWrt. These devices come with 128MB of storage – enough for OpenWrt and software, but not really enough for hosting file shares.
Picking a USB Storage Device
Most routers running OpenWrt will not be able to supply enough power to spin a mechanical hard disk. Avoid portable hard drives without their own power supplies or stick to USB sticks with flash memory.
If you are running OpenWrt on a Raspberry Pi, you should be able to get away with one, but any more may run into power limitations as well.
If you already have portable drives which lack their own power supplies, an externally powered USB hub can be used to ensure enough juice is supplied.
Configuring External USB Storage in OpenWrt
1: Install Dependencies in OpenWrt
SSH into your OpenWrt Box and run the following command to install of of the dependencies required to mount and format your usb disk:
opkg update && opkg install block-mount e2fsprogs kmod-fs-ext4 kmod-usb-storage kmod-usb2 kmod-usb3
2: Identify USB Storage
Warning: The following steps will delete all data on the USB storage device.
Ensure your usb storage device is unplugged.
List all attached USB storage devices (with the device you’re adding still unplugged) by running:
ls -al /dev/sd*
The list of current USB storage devices will be listed (or nothing will be displayed if there is no existing USB storage). Be aware that some internal USB storage may show as USB storage. If populated, the list will look something like this:
root@OpenWrt:~# ls -al /dev/sd* brw------- 1 root root 8, 0 Feb 4 15:13 /dev/sda brw------- 1 root root 8, 1 Feb 4 14:06 /dev/sda1
Note that there are two entries per device – we’ll be interested in the one that ends with a number.
Plug in your USB storage device and wait a few seconds for it to be detected.
ls -al /dev/sd*
…again. The new device will be shown in the list of USB storage devices – and you’ll know exactly which one of those devices is the new one, as it won’t have been shown in the initial list while the device was unplugged. Make a note of the name of the new storage device, it will be something like:
3: Format USB Storage
Format the device by running:
Make sure you replace ‘sda1’ with the name of the device as identified in the previous step
4: Update fstab with New Storage Device
fstab is the Linux configuration file which configures the storage available on the system. It must be updated to recognise the newly formatted partition.
This can be done automatically by running:
block detect | uci import fstab
To ensure the drive is always mounted when OpenWrt starts, run:
uci set fstab.@mount.enabled='1' && uci set fstab.@global.anon_mount='1' && uci commit fstab
5: Reboot OpenWrt
All you need to do now is reboot your router and your new storage will be available at
(Replacing sda1 with your device name, of course)
More details and configuration options can be found on the OpenWrt Wiki/