SOLVED: Simple USB Stick Installation Instructions for LEDE

SOLUTION FOUND

You need not read any further, unless you're curious: @bobafetthotmail created a Quick Start for Adding a USB Drive to address this issue.


Many useful programs such as squid, Samba, YAMon, etc. require the use of external storage. The easiest way to do this on modern routers is to connect a USB stick (or USB hard drive) to the router.

In my case, I "just want to connect my new 4GByte USB stick to my LEDE router" so I can use some of the software named above.

It would be an enormous service to the entire LEDE community for someone who knows how all this stuff works to create a simple HOWTO page on the www.lede-project.org wiki.

Requirements:

  • LEDE 17.01.0 or newer firmware
  • Router with at least 32MBytes of RAM and 64MBytes Flash (no swap needed, plenty of space for packages)
  • USB device of unknown filesystem and sufficient capacity (say, 1Gbyte or more)
  • Format the new storage for ext4
  • Mount the new storage in /opt
  • Written for a novice (that is, "Just do step1, step2, step3... and you're done")

Non-requirements:

The "USB Storage" HOWTO needs to focus on the items above, and doesn't have to address any of the factors below. In fact, the HOWTO shouldn't talk about these - they add complexity with no value to the issue at hand:

  • Don't worry about pre-LEDE software. We're all using LEDE. All the existing guides on the OpenWrt site have long sections about ancient software. There's no way to evaluate which of these apply to modern firmware.
  • Don't worry about filesystems that aren't ext4. We just want to wipe the data on the stick, and then use it with LEDE. Talking about other formats simply clouds the issue.
  • Don't worry about a LuCI package. It would be great to have a GUI that does this, but requiring SSH is fine.
  • Don't worry about options. We've already chosen LEDE firmware and a particular USB stick. We just want to install and use it, and don't care about alternatives. (If there are choices, the procedure should choose the sensible defaults that always work.)

Many thanks!

1 Like

I tried to follow the tutorial and also several posts on the OpenWrt forum and failed and then gave up.

 

It would be nice to have a new tutorial written on LEDE forums that are are not just copy pasted from OpenWrt.

The "crucial part" of extroot (at least for me) is when /etc/config/fstab is created for the fisrt time.

I din't know why, but after rebooting fstab doesn't contain the overlay mount point so in order to overcome this, I copy the contents of fstab before rebooting and after rebooting, paste them again in fstab.

A quick and dirty guide would be like this:

  • Prerequisites:
    cfdisk
    kmod-usb-core
    kmod-usb-storage
    kmod-usb-storage-extras
    kmod-scsi-core
    block-mount
    e2fsprogs
    blkid
    kmod-fs-ext4

  • You may also need (if not installed by default):
    kmod-nls-base
    kmod-nls-cp437
    kmod-nls-iso8859-1
    kmod-nls-utf8

Steps to follow:

  1. Use the cfdisk command to create an ext4 partition on /dev/sda

  2. Create the filesystem
    mkfs.ext4 /dev/sda1

  3. Prepare your external storage root overlay
    mount /dev/sda1 /mnt ; tar -C /overlay -cvf - . | tar -C /mnt -xf - ; umount /mnt

  4. Create fstab

block detect > /etc/config/fstab;
sed -i s/option$'\t'enabled$'\t''0'/option$'\t'enabled$'\t''1'/ /etc/config/fstab;
sed -i s#/mnt/sda1#/overlay# /etc/config/fstab;
cat /etc/config/fstab;

  1. Copy the fstab contents temporarily to a file

  2. Reboot

  3. Edit fstab and paste the contents you have previously copied in the temporary file (if the contents are the same, there is no need for that). Also add "option fstype". The file should look like this:

config 'global'
option anon_swap '0'
option anon_mount '0'
option auto_swap '1'
option auto_mount '1'
option delay_root '5'
option check_fs '0'

config 'mount'
option target '/overlay'
option uuid 'c91232a0-c50a-4eae-adb9-14b4d3ce3de1'
option fstype 'ext4'
option enabled '1'

  1. Reboot again and check with df command or alternatively in LuCI (System -> Mount Points) that everything is ok with the overlay and the rest of the partition table.

Normally you are done.

P.S: You probably won't need a swap partition but in the rare case you will, you can also install swap-utils and create a second partition using the cfdisk command which will be the swap. Also create the filesystem using "mkswap /dev/sda2" and follow the rest of the guide.

3 Likes

I am of the opinion that the released images should include USB functionality for those that have it, which is virtually every device made in the last 2 years. It should really just work, and I think very few who uses a precompiled binary would object. You do not have to use it.

It's the first thing I have installed on all my devices (sans 1 AP). It's a frequent request in the posts and source of new user pain. I expect the USB feature did not exist when the functional framework of features was developed. Even if it did, early on it may have made sense not to include this due to space limitations for packages. The LEDE (and OpenWrt) base image has not changed to keep up with modern hardware features and it seems like anything with 16mb or more of flash should not be an issue. OK, bring on the dissenters.

I created a Playground Page for USB Storage with my notes which summarizes a number of articles and my installation notes. It's 2 years old. It creates USB share for a basic data device with no users, it does not cover exroot. It is OpenWrt based, but I had no issue installing all this on my HooToo TM-02 (8GB) under LEDE 17.01.0, but the unit is now the AP referred to above. Hopefully someone can utilize this as an accelerator to build a new LEDE tool.

As I recall, fstab is not auto created and one gets a message about block mount not supported (not sure its been a while).

current LEDE wiki has a page for that, https://lede-project.org/docs/user-guide/start#installing_additional_software
"Installing new packages on an external storage device (extroot configuration). "

If you missed it or it is wrong/unclear then tell what you don't understand or how to improve it, or you can use it as a base for a simplified how-to if you so wish.
It is based on the openWRT extroot article but It's all tested personally and working in LEDE.

I am of the opinion that the released images should include USB functionality for those that have it

The release images have USB/Sata/whatever support built-in, so the USB/Sata/whatever controller is functional.
I mean kmod-usb2 and kmod-usb-ohci kmod-usb-ehci (and/or a kmod for usb 3 that I don't remember).

But kmod-usb-storage and filesystem drivers aren't usually included as USB can be used to connect whatever (USB relays/power switches or sound or whatever). I would personally add them too if the device isn't using 4MB flash, but I've seen some opposition when people tried to merge new devices with that support included.

While most devices with Sata do have at least ext4 filesystem compiled in the kernel, and work for storage ootb because that's the only thing Sata can do.

1 Like

@bobafetthotmail What's missing from the LEDE wiki is a single page with the procedure for installing an external storage device. (The page you cite tells about installing new packages on an external storage device. I don't want to do that - I want to use squid/YAMon/Samba/something else. So that page doesn't appear to be relevant to me.)

@RangerZ - I agree that USB support should be part of the mainline LEDE/OpenWrt distribution. Maybe we can prototype what should be available by default.

I wonder if our Resident USB Experts (@RangerZ, @angelos, @bobafetthotmail, anyone else?) might collaborate to write a HOWTO with a single goal: installing a USB storage device on LEDE. The steps should cover:

  • All the points of the original post: use a modern router, firmware, and USB stick, with enough RAM/Flash to hold all the packages that might be necessary, and format and mount the media in a known directory.
  • One file system that will work for all these uses, no swap partition required
  • Consider how much the current Samba, YAMon, squid, packages on external file storage, and other utility's instructions would need to change to use this default USB configuration (hopefully, not much)

Many thanks.

kmod-fs-ext4 is really large. It is a problem with 4 MB flash. Even with 8 MB, you may not want it included by default.

What's missing from the LEDE wiki is a single page with the procedure for installing an external storage device.

Ah sorry, misunderstood your question.
There is a page I wrote to deal with that here https://lede-project.org/docs/user-guide/start#additional_services
"Using storage devices"
https://lede-project.org/docs/user-guide/drives

Again, if it is not placed in a convenient spot or has an unclear name or has other issues please post it, and you can also use it as a base for a quicker tutorial.

Hi

I tried to cleanup the "drives" page a bit: https://lede-project.org/docs/user-guide/drives
(I've shortened it slightly and moved some advanced stuff to separate pages)

2 Likes

This is a good start, but I'm going to challenge you (and the other readers) to make it even shorter, with the single-minded goal of mounting a USB stick/drive on LEDE. (I would take a crack at it, but don't understand how this stuff works - yet.)

Don't worry about minimizing Flash/RAM space (we already said the router has at least 32/64 MBytes RAM/Flash). Don't worry about different formats/partitions/etc. Most people are looking for a single partition that can be used on LEDE, so just make intelligent default choices. The steps might tell the reader to:

  1. opkg install all-the-packages-we-will-need-in-one-go
  2. Insert the USB device
  3. Use some commands to find/identify the USB device
  4. Use that info to format/partition/mount/etc.
  5. Done! The new storage is available at xxxx in the filesystem

If there are any places problems might crop up, send readers to the Troubleshooting section, that explains options, etc. Don't clutter the 1-2-3 steps with alternatives. Many thanks!

1 Like

I tried to cleanup the “drives” page a bit: https://lede-project.org/docs/user-guide/drives1
(I’ve shortened it slightly and moved some advanced stuff to separate pages)

I like that, I just created links in main docs page to see them directly (and moved all storage articles to their own category)
See here https://lede-project.org/docs/user-guide/start#storage_devices

This is a good start, but I’m going to challenge you (and the other readers) to make it even shorter, with the single-minded goal of mounting a USB stick/drive on LEDE.

I can make a "quickstart" kind of thing, where I skip all checks and provide a blob of copy-paste shell code for automated partitioning/formatting.

But I'd rather keep the current longer guide too that does checks and explains and links around for those that actually care about understanding what they are doing.

That would be fantastic. It would make it so much easier for newcomers to get their USB drive "on the air".

Definitely. In fact, that longer guide might wind up having the Troubleshooting section that quick-start people can go to with questions. Thanks!

Ok, added https://lede-project.org/docs/user-guide/usb-drives-quickstart

I'm assuming ext4 filesystem (it's fine also for USB drives), and that the USB drive does not need to be re-partitioned, just re-formatted (which is the case for most data drives and thumb drives).

I recently flashed a router to LEDE... the steps I used to get USB working are summarized here: http://usage-monitoring.com/help/?t=openwrt-usb

Did I miss anything? (It worked for me)

@bobafetthotmail This is exactly what I wanted. THANK YOU!

I tried the procedure, and had to install two other packages (kmod-usb3, kmod-usb-storage) before the procedure worked.

I took the liberty of making an editorial pass over the instructions, and adding those two packages. Please check that I've left a working procedure. Thanks again.

Did I miss anything? (It worked for me)

It's correct, just that on most devices the kmod-usb drivers are already installed.
And yeah, starting and enabling the fstab service is better than making a mount -a like I do.

I tried the procedure, and had to install two other packages (kmod-usb3, kmod-usb-storage) before the procedure worked.

Ok, thanks for testing.
kmod-usb3 (and kmod-usb2) should be installed by default in devices that have USB 3.0 ports or (usb 2.0). Can you tell me what device is that so I can send a PR to add that package in its default list?

I added the kmod-usb2 too for the sake of having this work also when there are devices with USB 2.0 that lack the driver.

If you want a new memory stick to get mounted automatically, just change also that anon_mount to 1

@bobafetthotmail Thanks for updating the Quick Start

This happened on a Netgear WNDR3800 running LEDE 17.01.2 Thanks again.

This happened on a Netgear WNDR3800 running LEDE 17.01.2 Thanks again.

Hmm, that device does not have a USB 3.0 port so it should not need kmod-usb3. Can you try removing kmod-usb3 and see if it still works?

My goal was a procedure that would work on all LEDE devices, so including packages to support USB 2.0 & USB 3.0 would be important.

Am I correct that opkg installing a package that's not required (or is already present) has no effect, except perhaps to consume a bit more Flash memory?