Home > Uncategorized > Extend OpenWrt

Extend OpenWrt

November 9th, 2010 subogero

An OpenWrt router needs to be extended a bit to run big stuff. For instance to build a git-hub. The installed size of git is 91MB. One has an external USB HDD, of course, but what is the right way to do it? The forums are full of extroots and opts and similar stuff. I think they are all evil.

Extroot seems to involve compiling custom firmware images, while /opt brakes the nice Unixy directory structure (standard locations of programs, libs and daemons). There must be a better way:

Mount a partition of an external USB HDD to /usr

Just think about it. The really big files go to /usr/bin /usr/sbin and /usr/lib almost exclusively. Only small stuff goes to /etc, like config files and daemon startup scripts.

Today my theory was confirmed by practice. It’s very simple. These are the important steps:

1. Create an ext3 partition on your HDD just for this purpose

I actually did the partitioning before, on my normal Ubuntu laptop. It’s 2 GB and it’s called /dev/sda2 on the router.

2. Mount it to /opt temporarily

Create the /opt directory (or whatever else) temporarily and mount your partition into it using LUCI/Administration/System/Mount Points.

3. Copy the entire contents of /usr to /opt

The goal is that, initially, /usr looks the same with or without mounting something into it.

$ cp -dpr /usr/* /opt # preserve symlinks
4. Mount partition to /usr

Unmount /dev/sda2 from /opt, mount it into /usr using LUCI. You can also delete the temporary /opt directory.

5. Update /etc/opkg.conf

This involves OpenWrt’s most mysterious concept, overlay. Changing the line below has no effect except to calm down the worrying router about available storage-size for new packages:

option overlay_root /usr

You’re ready to install anything. As for me, I’ve since reinstalled mc and git. No dirty hacks this time with inserting /opt into PATH and manually creating some symlinks from /usr to /opt/usr. Just installed them like a breeze. My github is up and running again.

Categories: Uncategorized Tags: , , ,
  1. gergo
    November 10th, 2010 at 08:03 | #1

    When I put my home directory to a new partition I found this copy command to resolve the soft and hard links:
    $cd /home/
    $find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome/

  2. Fahad
    August 10th, 2011 at 02:02 | #2

    Excellent and thanks. Even Noobs like me can do it. Not relevant to this topic but can you also tell us about setting up hdd-spindown through hdparm etc. Thanks….

  3. August 10th, 2011 at 08:14 | #3

    I’ve never played with hdparm.

    hdparm -S 240 /dev/sda

    will set the spindown timeout to 20 min (240 * 5s).
    But to frequent spindowns and spinups actually wear out the HDD slightly.
    And my USB disk consumes only 1W power anyway, so why bother?

  4. adamisb
    October 13th, 2011 at 22:39 | #4

    another option is to mount the usr partition on your hard drive to somewhere else (eg: /mnt/usr) and then invoke:
    mount -o move /mnt/usr /usr
    Perhaps it is cleaner then directly mounting it over an existing mount point.

Comments are closed.