Netgear R6220 installing packages to reserved space

Today I was playing around quite a lot with my router. I wanted to put on it MotionEye, but I found one, quite big (or small, depending on how to look at it) problem – although R6220 has 128MB of memory installed, for packages only around 20MB is available. Quick googling explained problem:

As you can see on OpenWRT wbepage there is around 60MB reserved partition plus quite a lot of unused space. I found a lot of people just compiling their own versions of OpenWRT for R6220 with all that space connected into one, big partition, but unfortunately I’m not there yet, so I was looking for any way around.

I found multiple options to resolve space issue:

  • Compile custom image allowing use of all available space,
  • Using Extroot to move all files to external device,
  • Install packages using opkg to external device

The last option seemed easiest one – and I wanted something as simple as possible to not loose whole day on looking for solutions. So I decided to try that way. But… If I can install to external device, why not utilize those 60MB sitting there not doing anything?

Using instruction from website above I’ve unlocked that partition:

opkg install kmod-mtd-rw
insmod mtd-rw i_want_a_brick=1
ubiattach -p /dev/mtd5
ubimkvol /dev/ubi1 -N database -m
ubiblock -c /dev/ubi1_0
mkdir /tmp/ubi1
mount -t ubifs /dev/ubi1_0 /tmp/ubi1

Created script automatically mounting it:

root@WnekoWrt:~# vi /etc/init.d/ubimount
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011


boot() {

        insmod mtd-rw i_want_a_brick=1
        ubiattach -p /dev/mtd5
        mkdir /tmp/ubi1
        mount -t ubifs /dev/ubi1_0 /tmp/ubi1

chmod +x /etc/init.d/ubimount
/etc/init.d/ubimount enable

And now I have additional space availible:

/dev/ubi1_0 is the new partition, the screen was taken later, but after mounting for the first time it was of course empty.

Now I had to configure opkg to install to packages to that new location. I went to opkg configuration and added new install location:

I’ve added dest ubi1 /tmp/ubi1 line to add new destination for package installation.

Next to make sure OpenWRT will see package installed there I had to edit /etc/profile and add lines

export PATH=$PATH:/tmp/ubi1/bin:/tmp/ubi1/sbin:/tmp/ubi1/usr/bin:/tmp/ubi1/usr/sbin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/ubi1/lib:/tmp/ubi1/usr/lib

Ok, so let’s try if it works…

root@WnekoWrt:/# opkg install python -d ubi1
Installing python (2.7.18-2) to ubi1...
Installing python-base (2.7.18-2) to ubi1...

Great, it seems to be working! After it installed all required packages I’ve checked availible space in LuCI and it didn’t changed, I’ve also checked if files were in correct location – and they were. Small success. There was just small issue, as at first I was unable to invoke python, getting “not found” error, but after reboot everything started to work as expected.

So that’s it, now I was able to do everything I wanted using only inbuilt memory, it’s still not all of it available but I don’t think that I’ll need much more anyway, as I have on this router already all I wanted. But who knows… One day I must try with compiling my own images, but for now I don’t even want to risk, maybe one day when I’ll have spare one, this one must be working or I’ll be left without internet 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.