Table of Contents

Quick Start for Adding a USB drive

This page describes how to add a USB drive to your OpenWrt device. This is commonly used to add more storage or share files on your network.

Requirements

Procedure

USB drives can be installed using either LuCI or the command line as described below.

LuCI

1. On the Software page, click update, then install the packages. The instructions below use ext4 filesystem, however you can replace the final package with any of these: kmod-fs-ext4, kmod-fs-exfat, kmod-fs-ntfs3, etc.

  block-mount e2fsprogs kmod-usb-storage-uas kmod-usb3 luci-app-hd-idle kmod-fs-ext4

2. Plug in your USB drive, it will be detected automatically as /dev/sdXX depending on the drive and partitions.

3. Go to the System → Mount Points page, click on the drive to mount, click Save & Apply.

4. Go to the Services → HDD Idle page, enable to idle the drive to save power and lifespan, click Save & Apply.

Done! The drive is ready to read/write data.

Command Line

1. Use a computer to format your USB drive using the default options. This prepares the drive for the process below, which will erase those settings. Warning: This initial formatting will erase the entire USB drive.

2. SSH into your device to enter the following steps. More...

3. Install the required packages. Below uses ext4 filesystem, you can use any you prefer: kmod-fs-ext4, kmod-fs-exfat, kmod-fs-ntfs3, etc). More...

opkg update && opkg install block-mount e2fsprogs kmod-usb-storage-uas kmod-usb3 kmod-fs-ext4

4. Enter ls -al /dev/sd* to show all attached USB devices. The list may be empty if there are no USB devices. More...

5. Plug the USB drive into your router. Enter ls -al /dev/sd* again, now you should see a new /dev/sdXX device. sdXX is the device name of your new USB device. More...

    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

6. Make an ext4 filesystem on the USB device using the device name you just discovered. Note: Be certain you enter the proper device name - this step will completely erase the device. More...

mkfs.ext4 /dev/sda1

7. Create the fstab config file based on all the block devices found. More...

block detect | uci import fstab

8. Update the fstab config file to mount all drives at startup. More...

uci set fstab.@mount[0].enabled='1' && uci set fstab.@global[0].anon_mount='1' && uci commit fstab

9. Mount the device. More...

/etc/init.d/fstab boot

Done! The drive is ready to read/write data.

Network Shares

To share the drives (or even specific folders) on your network see Samba or Ksmbd.

More Details