40

How to increase storage on TP-Link WR703N with ExtRoot

tp-link wr703n with thumbdriveA 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.

Step 0

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 extroot a tp-link wr703n (1)  how to extroot a tp-link wr703n (2)

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).

Step 1

First you have to check if your router has recognized the USB flashdrive and if its firmware provides USB storage support.

ls /dev/sd*

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.)

how to extroot a tp-link wr703n (3)  how to extroot a tp-link wr703n (4)

#Update package list
opkg update

#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.

Step 2

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

Step 3

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 -
umount /tmp/cproot
umount /mnt/sda1

Step 4

Now need to make a small adjustment to the /etc/config/fstab file.

vi /etc/config/fstab

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.

how to extroot a tp-link wr703n (5)  how to extroot a tp-link wr703n (6)

#old
option target /home
option enabled 0

#new
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.

Step 5

Now you only have to restart your router.

reboot

After rebooting the router, connect again to it (via SSH). By subsequent command you can test, if everything worked fine.

#Show mounts
df

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.

how to extroot a tp-link wr703n (7)  how to extroot a tp-link wr703n (8)

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.

About the author: This article, as well as 140 more on en.code-bude.net, were published by Raffi. – Since 2011 I've been blogging here and on code-bude.net, the german counterpart, about programming and my software, write tutorials and try to share my knowledge, as well as possible, with my readers. Furthermore I write at derwirtschaftsinformatiker.de on subjects of my studies.
  //    •  • Facebook  • Twitter


  1. Fabio says:

    Hello,
    EXCELLENT guide!
    I have a 710N (quite similar to yours), and got only one (?) problem. I can’t get swap working on my flash drive! I know it could be dangerous for safety of the drive, but running Transmission is a really memory-consumpting task, and very often Transmission stops…
    Do you have any hint? Please, take note that flash drive is 32GB; output of fdisk -l is:

    Device Boot Start End Blocks Id System
    /dev/sda1 63 60741764 30370851 83 Linux
    /dev/sda2 60741765 60995327 126781+ 5 Extended
    /dev/sda5 60741828 60995327 126750 82 Linux swap / Solaris

    swapon /dev/sda5 ends with “block: failed to swapon /dev/sda5 (-1)”.
    It’s really frustrating…
    Thanks in advance, anyway!

  2. frank says:

    Works perfectly on airouter with Openwrt attitude 12.09.
    Thank you!
    How can I keep the contents of the usb flash drive after a reset?
    frank.italy.

  3. dan says:

    I followed your instruction but get a few different results when doing the last “df” command.
    What I did different though was to make three partition: sda1 = FAT32 for storage; sda2 = ext4 for extroot; sda3 = swap

    root@OpenWrt:~# df
    Filesystem 1K-blocks Used Available Use% Mounted on
    rootfs 960279 18014398509436883 954180 100% /
    /dev/root 2048 2048 0 100% /rom
    tmpfs 14608 896 13712 6% /tmp
    tmpfs 512 0 512 0% /dev
    /dev/sda2 960279 18014398509436883 954180 100% /

    So compared to your result.
    1) I am missing the “overlayfs:/overlay” line. Why?

    2) The “100% in use” for rootfs, /dev/root and /dev/sda2 is obviously wrong. In the WebUi (Mount Points / Mounted file systems) I get more realistic numbers for “Available” (eg 931 MB / 937 MB), however hte “Used” column is off again (100% 16777216 TB).
    Any Idea why?
    What irritates me a bit is that in the table below “Mount Points” only the enabled mark for the storage sda1 is checked and not the sda2 one. Is that correct?

  4. Rodrigo says:

    It worked in my tp link mr3020, thanks a lot. I have a doubt, if the usb stick is damaged i can´t boot my router again? I should make an backup image of the usb disk?

    Thanks in advance

    • Raffi says:

      Certainly it does not hurt to make a backup of the stick. Nevertheless the router should work without the stick (of course in limited mode without the adjustmends you’ve taken while the stick was plugged in).

      In the improbably case of a total failure you could reset/repair the router in failsafe mode. (See paragraphs “Failsafe mode” and “Back to original image” http://wiki.openwrt.org/toh/tp-link/tl-wr703n)

  5. 3020 says:

    I have only 15% memory remaining on my 3020 router and it won’t let me install any more packages, not even kmod-fs-ext4 which is necessary for extroot to work. Is it possible to to use ntfs instead of ext4 because I already have ntfs packages installed ?

    • Raffi says:

      Hm, I think this won’t works with NTFS. So factory reset your router, then ExtRoot it and after that install packages like NTFS…

  6. Ian says:

    Great article! I’ve used this so many times I can almost remember it :)

  7. Stan says:

    Thanks for providing this information in an easy to use format. I see several people are having problems as their USB drive isn’t coming up as expected. My ext4 partition didn’t show up as sda1 either, but this didn’t surprise me. Maybe you should update the instructions to indicate that sda1 may not be the correct partition and suggest how they identify which one, and how they should change the commands to match.

    Thanks again!

  8. load.nikon says:

    I ran into a problem when I tried to do this where I had formatted a 16GB drive with 8G of FAT32, 100MB linux swap, and the rest to ext4. I followed your directions exactly, half figuring that it would fail because ls showed 5 different sda things. After getting a nasty “you’re out of space” message, ds showed sda7 was the one I wanted to make the extroot point to for storage. ds did not show the FAT32 partition so that narrows things down for my following question.

    While following your instructions above, how do I point out the linux swap partition (once I figure out which sda* it is?

    here’s the ds I got:

    root@OpenWrt:~# ls /dev/sd*
    /dev/sda /dev/sda1 /dev/sda5 /dev/sda6 /dev/sda7
    root@OpenWrt:~# df
    Filesystem 1K-blocks Used Available Use% Mounted on
    rootfs 1088 1016 72 93% /
    /dev/root 2048 2048 0 100% /rom
    tmpfs 14608 460 14148 3% /tmp
    tmpfs 512 0 512 0% /dev
    /dev/mtdblock3 1088 1016 72 93% /overlay
    overlayfs:/overlay 1088 1016 72 93% /
    overlayfs:/overlay 1088 1016 72 93% /tmp/cproot
    /dev/sda7 6693988 12522 6324551 0% /mnt/sda7
    root@OpenWrt:~#

    • load.nikon says:

      Uh, sorry. That last bit didn’t display here very nicely…

    • john says:

      Hi Load.Nikon
      I to am getting exactly the same scenario as yourself with multiple sda’s & I dont seem to be able to run these commands without throwing up an error.
      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 –
      umount /tmp/cproot
      umount /mnt/sda1

      Did you manage to sort this out & get this working?

      Regards
      john

  9. […] How to increase storage on TP-Link WR703N with ExtRoot […]

  10. blgoh says:

    Hi Raffi ,
    I am new to linux. However I managed to install madox image dated Oct 2012 when I first got my 703N. It is working perfect as a client and AP. Recently I managed to extroot using 4gb flash drive as per your instructions. Later I attached a 4 port USB hub and attached the 4gb flash drive, a printer, a usb DAC and also a hard disc drive. I managed to install MPD by following instructions your instructions and succeeded to output music to my earphone. I also managed successfully to install the printer software.
    Regarding the MPD, I copied only one wav file to the 4gb flash for testing purpose. All my wav files are in the usb hdd, how do I go about accessing the hard disk drive?
    All the items were available when I issued a lsusb command.

    • Raffi says:

      You should “mount’ your harddrive. Maybe you have to install some stuff to support the filesystem (like NTFS) of your harddrive. At which point do you stuck?

      • blgoh says:

        HI Raffi,
        When I replaced the usb hdd with a flash drive, it was mounted as shown on Luci. Let’s say if I ever managed to get the hdd mounted later on, how do I go about linking my MPD music directory to the hard disc drive which contains all my music files.

  11. […] Expand TL-WR703N’s memory using ExtRoot […]

  12. sanja_nvkz says:

    Thanks, works like a charm!

  13. Nathan says:

    After this, what will happen if my flashdrive breaks down? I don’t want to brick my router for this.

    • Raffi says:

      The router config will be dropped and extroot feature will be forgotten by the router. It will run like it has run before you added the extroot feature.

      Nevertheless you should simply clone your usb thumbdrive, so that you have one if the first dies or gets lost.

  14. Aquoibon says:

    It works,cool~!!
    Thanks for your tutorial.

  15. seko says:

    I tried it with an SD card and it worked! Thank you!!!

  16. tyler roberts says:

    is it posible to do this with an sd card?

    • Raffi says:

      This should be also possible. Just try it. I think an usb sd card reader/writer in combination with a sd card should work.

      If you tried it and had success (or whatever failed), please leave another comment, so that I can share your experience with the other readers of my blog.

  17. toketin says:

    I tried to set transmission-daemon on this Wr703n, but it crashes down after about 10 seconds. Do you guess this is a lack of ram problem?

  18. toketin says:

    Thanks great guide :D

  19. steven says:

    Hi,guys.I found a portable power bank specifically designed for TP-Link mini wireless router WR702N and WR703N,you can order it at http://igg.me/at/sofa/x/989539.

  20. rmanna says:

    thanks for the tutorial btw :)

  21. rmanna says:

    in step 3, “mount /dev/sda1 /mnt” should be “mount /dev/sda1 /mnt/sda1″