# OpenWRT: Expand Storage Space and Memory

When using OpenWRT on relatively cheap routers, low memory and storage becomes a bottleneck, preventing you from installing a lot of packages and really unleashing the true computing power of your router. In this tutorial, we are gonna use a USB storage device (Flash Drive, Portable Hard Drive or whatever) to expand our memory. Now it’s time to get our hands dirty!

> And, if you didn’t know about OpenWRT, it is a third-party after-market firmware available for many routers. (You can think of it as Cyanogenmod for Routers)

## What you need

* A Router with a USB port and OpenWRT 12.09-rc1 or greater installed
    
* A USB Storage Device (Flash Drive, USB HDD, Memory cards…)
    
* A good partitioning tool (I suggest GParted)
    

It’s a good idea not to use memory cards like SD or MicroSD, they are prone to read-writes and might wear out very soon.

## Partitioning the storage

I am using a 4GB USB Flash Drive as my storage device. Just plug it in to your system and launch your partition manager. Remvoe previous partitions and create two new partitions.

* An ext3 partition –&gt; 3GB
    
* A swap partition –&gt; 768MB
    

Actually you don’t need that much of swap, you can allocate as much memory as you want. Just remember four things,

* The ORDER is important. The ext3 should be the FIRST partition, swap should be the second one.
    
* The ext3 one will hold your data, programs and all other stuff.
    
* The swap partition will act as a boost of RAM.
    
* The frequent swap read-writes WILL reduce the lifespan of your USB flash storage. (Not a problem with Hard Drives)
    

## Mounting the device

1. Connect the USB Storage Device via the USB port of your router.
    
2. Login to the `OpenWRT Control Panel` with your browser.
    
3. Go to `System` &gt; `Mount Points` from the menu. You will see your device getting detected.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1708357994591/b5f83637-db64-470a-b3d9-06c05e5b0480.png align="center")
    
4. Now, click on the edit button of the `/dev/sda1` device.  
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1708358026725/7d25bf83-5c7e-444d-bea6-7d5d43f31654.png align="center")
    
5. Check `Enable this mount`, select `ext3` as the `Filesystem`, check `Use as root filesystem` and finally click `Save and Apply`.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1708358056610/73edf7d8-a09f-4b98-8467-afc8b31d847f.png align="center")
    
6. Come back to System &gt; Mount Points, and click the `edit` button of the `swap` partition. Check `Enable this mount` and click `Save and Apply`.
    
7. Now reboot the device from `System` &gt; `Reboot`.
    

## Knowing if we are successful

1. Login to your router console via SSH.
    
2. Run the commands `df -h` and `free`!
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1708358072944/498083b0-cd66-4105-90b4-a83a452aac20.png align="center")
    

Yeppi! Now you have a boost of storage and memory ready!
