User Tools

Site Tools


docs:guide-user:storage:usb-drives-quickstart

Quick Start for Adding a USB drive

Many useful OpenWrt utilities and packages rely on external storage to hold data files. This guide describes how to add a single USB stick or drive to your OpenWrt device.

Note: If you have a memory limited router (say with 4MBytes Flash internal storage), and want to be able to install more packages, you should instead read the Extroot Configuration page.

Note: For NTFS disks, refer to https://openwrt.org/docs/guide-user/storage/writable_ntfs

Requirements:

  • Your device/router itself must have at least 8 MB Flash. Lower capacity devices will not be able to hold the required packages.
  • The USB drive you're adding can be of any capacity.
  • This procedure WILL ERASE THE USB DRIVE. Copy any data you care about to another destination.
  • This quickstart requires you to ssh into the router.

Procedure:

1. Use your laptop/desktop computer to format your USB device. Use the default name and format options. This prepares the USB drive for the process below, which will erase those settings (again). Warning: This initial formatting will erase the entire USB drive.

2. SSH into the router and enter the following commands into the SSH window.

3. Update and download required packages: More...

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

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

5. Insert the USB drive into your router. Enter ls -al /dev/sd* again, and this time you should see a new /dev/sdXX device. This is the name of your new USB device.

  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 name of the new USB device. Note: Be certain you enter the proper device name - this step will completely erase the device. More...

mkfs.ext4 /dev/sda1

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

block detect | uci import fstab

8. Ensure the new drive will be mounted at startup. More...

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

9. Mount the device and enable the fstab service so the new configuration will be applied after a reboot.

/sbin/block mount && service fstab enable

10. You're done! By default, this procedure mounts the drive at /mnt/sdxx (whatever the device name was.) The drive is ready to save data at that part of the filesystem. You can change the mount point in the web interface, in SystemMount Points menu, or look fstab for configuring from the command line.

More Details

If you want more information about this procedure, see the full USB Drive tutorial. Or check the forum article that contains background information for this note at: https://forum.openwrt.org/t/more-on-usb-drive-installation/30695/2

docs/guide-user/storage/usb-drives-quickstart.txt · Last modified: 2019/03/29 21:41 by mhegab