A few days ago I wrote about how you can flash OpenWRT on the TP-Link WR703N router and build a ~20$ cheap OpenWrt router this way. OpenWrt actually works quite well on the WR703N, but in retrospect the following problem arises.
Unfortunately the WR703N has only 4MB flash (memory), so (depending on the selected image/firmware) after installing OpenWrt there will be just about 900 kB of free memory available. If you now want to install one or more extensions for OpenWrt, which in my opinion is one of the main benefits of using a OpenWrt system, you will be confronted with “no space available” messages in really no time. One solution to “bypass” this problem is to “ExtRoot” your router.
ExtRoot is a functionality that can be used to outsource the OpenWrt file system of the router to an external storage medium. This can be for example a USB flash drive or an external hard drive. How to set up the TP-Link WR703N for the ExtRoot feature is what I want to show you in the following.
ExtRoot on the TP-Link WR703N
For following instructions, I decided to use a USB thumbdrive for the outsourcing of the file system. However it would be possible (as described above), to use an external hard drive for example.
Before we can start, a USB flashdrive with the ext4 file system is needed. Theoretically you could create these directly under OpenWrt on the router, but I hadn’t enough memory to install both, the format tools for USB flash drive and the tools for ExtRoot, on my TP-Link WR703N. So I had to create the ext4 USB flashdrive by the help of my computer.
How to create a USB thumbdrive with ext4 file system on Linux, you can read here (with gui) and here (by Shell). How you can create a USB stick with ext4 file system on Windows, I have described here.
If you’ve prepared your USB flashdrive, plug it into the WR703N and log in to the router by using SSH (e.g. with Putty).
First you have to check if your router has recognized the USB flashdrive and if its firmware provides USB storage support.
The above command should list all external drives. If the result of the command is empty, you need to install the package for USB storage support. (Previously you should update the package list.)
#Update package list
#Install USB storage support
opkg install kmod-usb-storage
After successful installation of the package you can try to run the first command (“ls /dev …”) again. Now you should see your USB flashdrive listed up in the output of the command.
Next we need to install the packages that are needed for ExtRoot and ext4 file system support. This works by subsequent command.
opkg install kmod-fs-ext4 block-mount
Now we copy the file system to the USB drive. (One command per line.)
mkdir -p /mnt/sda1
mount /dev/sda1 /mnt/sda1
mkdir -p /tmp/cproot
mount --bind / /tmp/cproot
tar -C /tmp/cproot -cvf - . | tar -C /mnt/sda1 -xf -
Now need to make a small adjustment to the /etc/config/fstab file.
Within vi you can change into the edit-mode by pressing the i-key. Then you have to change the following two lines inside the config mount-block.
option target /home
option enabled 0
option target /
option enabled 1
By pressing the ESC-key you can leave the edit-mode of vi. With ! you enter the command-mode. With :w you can save your changes and with :q you can close vi if you’re ready with the editing.
Now you only have to restart your router.
After rebooting the router, connect again to it (via SSH). By subsequent command you can test, if everything worked fine.
In the line rootfs you should now see that the storage capacity is the same as the one of your USB flash drive. A look into the router’s web backend (at the System->Software tab) should also disclose whether everything went fine.
That’s it. The article may look like it’s a lot of work to get things done, but don’t be scared by that. It’s done really fast and if you have any questions, then don’t be afraid to write me a comment.