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.

54 Comments

  1. Geosays:

    can some one help us all .. there is no solution. Even after reseting it complaints saying no space in Overlay for lastest 17 version firmware. We cant proceed to install or mount the usb.

  2. gatsays:

    hello help me
    dev/sda1 2048 526335 524288 256M 82 Linux swap / Solaris
    /dev/sda2 * 526336 62683135 62156800 29.7G 83 Linux/etc/config/fstab
    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 ‘/mnt/sda2’
    option uuid ‘5c438543-4c22-4bf7-abb4-d5da9aaf1acb’
    option enabled ‘1’
    option enabled_fsck ‘1’
    option fstype ‘ext2’
    option device ‘/dev/sda1’

  3. Zoesays:

    Hey
    I have gone through your post and its very informative
    I have tested extroot method with root overlay a long time ago with attitude adjustment firmware and I ran into certain issues like my router doesn’t boot after removing usb and it runs fine when its plugged back so I stuck with original firmware and bare necessary packages for it to operate.
    Now its two years from then and I have installed chaos calmer and looking for root overlay but my previous bad experience is making me think over.
    Lets say we did all that and its running fine then how about upgrade when next version comes.
    Should I remove usb and upgrade and attach usb and rewrite all the new files and packages with newer config against new packages or there is an easy way out.

  4. note !

    In the OpenWrt ‘Backfire’ 10.03 release there is a bug. Solution is: vi /etc/init.d/fstab and put a # in front of the line:
    echo ‘# WARNING: this is an auto generated file, please use UCI to set defined filesystems’ > /etc/fstab

  5. To make step 4 work. After you modify the /etc/config/fstab file, make sure you run the command: “/etc/init.d/fstab enable”.
    This command will ensure that fstab will start [and your modifications are being noticed] every time your router / computer boots.

  6. milohazesays:

    Hello,

    I can’t install block-mount, the system reports out of space.
    I haven’t installed anything else but the USB and EXT4 packages.
    The device is brand new, ver 1.6 (according to the label on the back).
    Any idea what to try next?

    Thanks.

  7. izzatsays:

    hi,

    im stuck at step no 2. i get this error:

    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/base/block-mount_2015-05-24-09027fc86babc3986027a0e677aca1b6999a9e14_ar71xx.ipk.
    Configuring kmod-crypto-hash.
    Configuring kmod-lib-crc16.
    Collected errors:
    * wfopen: /lib/modules/3.18.20/mbcache.ko: No space left on device.
    * extract_archive: Cannot create symlink from ./etc/modules-boot.d/30-fs-ext4 to ‘../modules.d/30-fs-ext4’: No space left on device.
    * wfopen: /etc/modules.d/30-fs-ext4: No space left on device.
    * pkg_write_filelist: Failed to open //usr/lib/opkg/info/kmod-fs-ext4.list: No space left on device.
    * opkg_install_pkg: Failed to extract data files for kmod-fs-ext4. Package debris may remain!
    * opkg_install_cmd: Cannot install package kmod-fs-ext4.
    * wfopen: //usr/lib/opkg/info/block-mount.control: No space left on device.
    * wfopen: //usr/lib/opkg/info/block-mount.postinst: No space left on device.
    * wfopen: //usr/lib/opkg/info/block-mount.prerm: No space left on device.
    * wfopen: /lib/libblkid-tiny.so: No space left on device.
    * wfopen: /sbin/block: No space left on device.
    * extract_archive: Cannot create symlink from ./usr/sbin/swapoff to ‘../../sbin/block’: No space left on device.
    * extract_archive: Cannot create symlink from ./usr/sbin/swapon to ‘../../sbin/block’: No space left on device.
    * wfopen: /etc/init.d/fstab: No space left on device.
    * extract_archive: Cannot make dir /etc/hotplug.d/block/: No space left on device.
    * wfopen: /etc/hotplug.d/block/10-mount: No such file or directory.
    * wfopen: /etc/uci-defaults/10-fstab: No space left on device.
    * set_flags_from_control: Failed to open //usr/lib/opkg/info/block-mount.control: No such file or directory.
    * pkg_write_filelist: Failed to open //usr/lib/opkg/info/block-mount.list: No space left on device.
    * opkg_install_pkg: Failed to extract data files for block-mount. Package debris may remain!
    * opkg_install_cmd: Cannot install package block-mount.
    * opkg_conf_write_status_files: Can’t open status file //usr/lib/opkg/status: No space left on device.

    im doing this on a newly flashed mr3020.

    thanks

  8. Jose Colinsays:

    Excelent…. I followed this tutorial for my TL-MR3420v2 and openwrt 15.05 chaos calmer….

    in step 4 is diferent since fstab changes….. so I this this

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

    config ‘mount’
    option target ‘/’
    option enabled ‘1’
    option device ‘/dev/sda1’

    saving changes…… and DONE an SUCCESFUL

    reboot

    then luci software show increase storage 7gigas

    then as test I reboot without USB… then as was told here I could get into openwrt succesfully with my old config and storage of 104kb….

    thanks for this exelent tutorial…..viva mexico

    • briansays:

      how did you get it to work on MR3420 ver 2.4? what image did you use?

  9. Cleito de Carvalho Juniorsays:

    ITs Working in my TP-3020, but when I Reboot and go to fstab config file there’s a default file.

    I can view the fstab file that i’ve beem worked? I searched in /overlay but is empty.

    Thanks.

  10. Hi, I was just wondering if i copy all the neccessary files into the usb and start from usb, what happens next time if i lost my usb?

    • If you loose your usb stick, your router will boot without all settings you’ve made. So take an image tool and dump your whole usb-stick to an image, so you can recover the image if you loose the stick.

  11. Cleito de Carvalho Juniorsays:

    Man, your article is very good.

    It’s help me a Lot… it’s working in a TP-LINK MR3020.

    Thanks!

  12. hfe18says:

    in step 3

    “mount /dev/sda1 /mnt/sda1” will show “failed :Invalid argument ”

    please help me, how to rectify this

  13. Herman Egginksays:

    Hi Raffi,

    I have a v1.7 703N that runs openwrt BB using bugblue’s exploit. I would like to update uboot as well but I was foolish enough to flash with stock BB which disables write access to mtd :-(.

    Using this approach, instead of moving the rootfs, could I install a custom openwrt that allows write access?

    Thanks!

    H

  14. Martini Mansays:

    For the new version of OpenWRT the Step 4 dont work!
    Can you help?

    • Have you seen this article and especially the parts about “r36988” and “block-mount”?

  15. 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!

  16. franksays:

    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.

  17. 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?

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

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

  19. 3020says:

    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 ?

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

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

  21. 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!

  22. load.nikonsays:

    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.nikonsays:

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

    • johnsays:

      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

  23. blgohsays:

    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.

    • 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?

      • blgohsays:

        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.

  24. sanja_nvkzsays:

    Thanks, works like a charm!

  25. Nathansays:

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

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

  26. Aquoibonsays:

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

  27. sekosays:

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

  28. tyler robertssays:

    is it posible to do this with an sd card?

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

  29. toketinsays:

    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?

  30. toketinsays:

    Thanks great guide :D

  31. stevensays:

    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.

    • Looks really nice. Thanks for the tip. Hope the crowdfounding project will be successful.

  32. rmannasays:

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

Leave a comment

Please be polite. We appreciate that. Your email address will not be published and required fields are marked