How to setup OpenWrt extroot, rootfs on USB storage

Here I’m going to share my experience with OpenWrt extroot on a TP-Link MR-3220 v2.4 router.

Though I did this on a MR-3220, this guide also applies to other routers like TP-Link WR703N, MR3020, D-Link DIR-505 etc etc. Just make sure you have downloaded the correct firmware for your router.

Probably you know all about it’s hardware specifications, here is a short recap again

  • AR9331-AL3A 400MHz SoC
  • 32 MB DDR RAM chip
  • 4 MB SPI NOR flash memory
  • One 10/100M ethernet WAN port
  • Four 10/100M ethernet switches
  • 150Mbps b/g/n Wi-Fi
  • One USB 2.0 port

Little about MR 3220 v2.4 hardware quality, I teared it apart within 1 hour of receiving, the hardware quality is average with average quality components.

Enough hardware introduction, lets start the main topic, installing OpneWrt and configuring extroot on a USB pendrive. OpwnWrt firmware installation is very easy through the web interface and openwrt extroot part is same for almost any other router too.


Which OpenWrt firmware version should I choose ?

This is one of the most important question, choosing the correct OpenWrt version is absolutely crucial. This router works perfectly with the latest OpenWrt trunk (Designated Driver), stable 15.05, 14.07 or 12.09 .

But OpenWrt is bloating day by day while limited NOR flash storage is not, the stable firmware is also bloated with LUCI web interface. The free JFFS2 space after installing OpenWrt is decreasing too. So you can’t install more than a few package with this limited space, that’s when putting extra files on a external drive is necessary.

After about 12-14 hour  experiment with various OpenWrt versions, I figured out that only OpenWrt 14.07 (Barrier Breaker) or earlier versions have the right amount of free JFFS2 space to install required bare minimal minimal packages to setup an extroot.


Which filesystem should I use for extroot ?

Another very important question, the official OpenWrt extroot guide says that you could any UNIX-like filesystem of your choice, forget about FAT32 or NTFS. But the reality is extroot is only and only possible with ext4/ext3 or ext2 filesystem. I tested with almost every slim (I mean which equips less NOR flash space) filesystem

  1. minix, not supported
  2. HFS, not supported
  3. HFS+, not supported
  4. JFS, not supported
  5. XFS, not sopported
  6. reiserfs, not supported

There are other UNIX-like filesystems like BTRFS, LVM2 PV , UFS etc. but none of them will fit in the 288 KB free JFFS2 space, so I didn’t tested them.

So the final choice is for a router with 4MB flash, choose only OpenWrt 14.07 or earlier and ext4 as extroot filesystem.

Request to OpenWrt pro users, if you had ever setup chroot with any other filesystem except ext4/ext3/ext2, please mention.


Installing OpenWrt on TP-Link MR3220

Assuming you have a PC running a Linux distribution, this is required for flashing the firmware and

Download the OpenWrt 14.07 firmware from here .

 wget -c

WARNING: Do it at your own risk, event with great precautions there is a chance of bricking the router. If possible connect the router to an UPS before flashing it.

  1. Power on the router and connect a PC through a ethernet straight cable (patch cord) to one of four the LAN ports(the yellow ones).
  2. Open up a browser and go to this address; to access the web interface and login. Username: admin Password: admin .
  3. Go to the System Tools > Firmware Upgrade choose the previously downloaded OpenWrt firmware with the Browse button and Hit the Upgrade button.
  4. Wait for few minutes to let the flashing complete and automatic reboot.

Installation is complete now your PC will automatically receive a different IP via DHCP.


Initial OpenWrt setup

For first time we have to use telnet to login into OpenWrt,


or if you don’t have telnet try this

 busybox telnet 

after login, change the password to enable ssh

 passwd root 

now exit from the telnet session with exit command and re-login with SSH,

 ssh [email protected] 


Installing necessary packages

At this step the router must be connected to the internet, you could use your existing DSL/cable internet for this purpose or share an existing connection from your PC. I personally did it by sharing my 3G connection with Network-Manager from my laptop.

Make sure that the router could connect to the internet

 ping -c 4 

Update opkg package repository

 opkg update 

Install necessary packages to support USB storage device

 opkg install kmod-usb-storage kmod-scsi-core block-mount 

Install ext4 filesystem kernel module

 opkg install kmod-fs-ext4 

That’s all, check free flash space with df -h , do not install anything more ! if you try to do so, any packages larger than 10KB will return no space left on device error.

OpenWrt df command

Now load all necessary kernel modules with modprobe command

modprobe sd_mod
modprobe usb-storage
modprobe ext4

or simply reboot the device with reboot command.


Partitioning the USB drive

Lets partition the USB drive, another question, how much space should I use for extroot partition ? Just 100-200 MB is more than enough, I allocated a 200 MB ext4 partition for extroot, you could use more if you wish.  I used Gparted for partitioning a 4 GB USB drive.

OpenWrt extroot disk partitioningNow safely remove the USB drive and plug it in the routers USB port.


Configuring the OpenWrt extroot

After plugging the USB drive, it should show up as a storage device under the /dev directory as /dev/sda1 , /dev/sda2 etc. Simply go through the commands bellow

Mount the USB drive, change /dev/sda2 according to yours

 mount /dev/sda2 /mnt 

Copy data from /overlay partition to the USB drive

 tar -C /overlay/ -c . -f - | tar -C /mnt/ -xf - 

Un-mount the USB drive

 sync && umount /dev/sda2 

Configure /etc/config/fstab to mount the USB drive as /overlay partition

 block detect > /etc/config/fstab 

Now edit the /etc/config/fstab with vi to mount the etxt4 partition (/dev/sda2) at /overlay partition at startup,

vi /etc/config/fstab 

have a look on a sample fstab configuration,

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  '/overlay'
       option  uuid    '7669178c-3f77-4fb1-b421-6ec6f61be672'
       option  enabled '1'

Set the target to /overlay, and change the option enabled line from 0 to 1 . Now enable the fstab service at startup

 /etc/init.d/fstab enable 

and check it

 readlink -f /etc/rc.d/*fstab 

reboot the router with the reboot command



Check if the extroot is working or not

After the reboot is complete login to the router with ssh again and check the free disk space with df and mount command.

df -h


The df commnd should return a lot of free space available at rootfs, that means extroot is working fine.

OpwnWrt extroot free spaceNow check it again by installing some big packages, example >

 opkg install e2fsprogs 


I hope this simple beginner friendly tutorial will help you to start your experiment with OpenWrt. If you have any question or suggestion, just leave a comment and don’t forget to share this with your friends 🙂 .

46 Responses

  1. N says:

    Hi, Thanks a lot for this great tutorial, I have a router with open wrt installed on it and i want to re install the version that you mentioned, i am new to linux so can you please show me how to do that.


  2. ali yazdani says:

    hi i want to turn my router into wifi marketing router . for sharing my videos and … i need to install LAMP on my router at least . i wonder if this tutorial give me a chance to install php,mysql,apache on a usb stick?

    • Arnab says:

      Hi, it depends on your routers available system resources, LAMP is very IO intensive, specially mysql. And Apache is a known memory eater.

      You could try that with uhttpd , or better lighttpd.

      For sharing videos, I’ll suggest you to have a look at Piratebox.

      • ali yazdani says:

        tnx i tried piratebox last week,in my case it’s so complicated solution for developing
        i found a chinese router called “Xiaomi Mi Wi-Fi Router” 128MB ram , this router use’s Mediatek MT7620A which offer’s excellent usb data transfer speed.
        i will use lighttpd and sqlite , if you are interested in this case , i’ll be happy to share with you my experiense,wish me luck dude!!!

  3. zordon says:

    I’ve tried a lot, Thank you, very important info that TP-LINK MR3220 v2 works only with 14.07 barrier breaker 🙂 Algoritmh works like a charm. Greetings from Hungary

  4. zordon says:

    Oh by the way, works fine with my MR-3220 V2.0 (and not 2.4) version.

  5. killerjatt says:

    hi can i install multiwan mw3 on it?. i have mr3220 2.4 router..

    • Arnab says:

      I think you can’t setup multiwan using two Ethernet ports, as far as I know TP-Link MR3220 doesn’t support VLAN.
      But WAN connection from a 3G modem could do multiwan.
      Anyway you could check the OpenWrt forum.

Leave a Reply

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