Installing ipkg on Tomato USB for Asus RT-N16

Hits: 758

Next step is to enable ipkg as I used to have on Oleg firmware. And here the problems start. Tomato web site does not contains any useful “how to” on how to enable ipkg support, instead they send you to dd-wrt wiki, which is quite messy, and it is all about using ipkg on/jffs .

I dislike this solution, yes, it is simple – just enable /jffs and you have ipkg working, but I don’t want my router’s flash to wear out. I also want to store big amount of files and for that I want to use my old USB 4 Gb size flash drive.

So, the task is to enable ipkg on Tomato Mod USB and use for ipkg USB flash drive, not the /jffs. This task can be split into two logical parts:

1. Mounting USB flash drive to /opt

2. Installing ipkg to /opt

Mounting USB flash drive to /opt

The first part will be done manually, while the second will be automated using script. Let’s make sure we have necessary things:

– USB flash drive of average size, mine is 4 Gb

– RT-N16 router

– Software to partition USB drive in EXT3

– Time and patience

First, let’s enable USB support on Tomato. Enable the following checkboxes and reboot router:

It is necessary to partition USB drive in EXT3, as most of them has FAT32. For that I usually use gparted tool, which can be installed like this:

In Ubuntu:

sudo apt-get install gparted

In Fedora:

sudo yum install gparted

In Windows: use appropriate software which allows to create ext3 & swap partitions.

Attention: it destroys your data on USB flash.

So, plug your USB drive, start gparted and remove FAT32 partition. Create first linux-swap partition of size 512 Mb and afterwards EXT3 partiton of remaining size. Apply changes and exit gparted.

Plug-in USB flash to RT-N16 and connect to router via SSH or telnet. Issue the following command:


It should output something like this:

scsi 0:0:0:0: Direct-Access USB2.0 Flash Disk 1.00 PQ: 0 ANSI: 0 CCS
sd 0:0:0:0: [sda] 7989248 512-byte hardware sectors (4090 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] Assuming drive cache: write through
sda: sda1 sda2

Which means for us that router “sees” USB flash as /dev/sda1 and /dev/sda2 .It may be different for you, so please perfom steps below accordingly to the device label you have! Now we need to mount it to /opt permanently, so each time router starts it automounts it as /opt. For this we have to create file /etc/ fstab using vi:

Enter the following:

vi /etc/fstab

Press “i” to enter insert mode and insert the following content into the file (note that if you are using putty ssh client clicking by the right mouse is acting like Paste, so you can copy paste the content below using right mouse):

#device Mountpoint FStype Options Dump Pass#

/dev/sda1 none swap sw 0 0

/dev/sda2 /opt ext3 rw,noatime 1 1

Now press twice Esc and then “:x” so that the vi is exited and the file is saved into temporary flash.

Now we have to make file /etc/ fstab permanent and store it in resident flash. Perform the following commands:

nvram setfile2nvram /etc/fstab

nvram commit


Now wait until the router gets rebooted. When it reboots connect using ssh or telnet and issue the following command:


It should show all mounted partitions, mine output is:

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/root 5632 5632 0 100% /

tmpfs 63500 132 63368 0% /tmp

devfs 63500 0 63500 0% /dev

/dev/sda2 3414824 104528 3136832 3% /opt

We see that the /dev/sda2 is mounted as /opt which is correct. We can enter /opt and try to create a folder there:

mkdir /opt/bazinga

cd /opt/


should show the folder bazinga. If it does not show, something went wrong (Please see section Troubleshooting at the end of this article).

You are done here. Skip text below if you don’t have time reading some hacks, and go directly to “Installing ipkg to /opt” section.

Now we have to download ipkg from optware and try to run it. But if I run it, I got the following error:

ipkg update


wget: unrecognized option `–passive-ftp’

Collected errors:

ipkg_download: ERROR: Command failed with return value 1: `wget --passive-ftp -q -P /tmp/ipkg-NwbY01 '

It seems like ipkg is trying to invoke wget with an option, which it does not have, because most likely Tomato Usb uses an old version of wget. There should be no despondency; this problem can be also solved by searching patterns of wget in ipkg binary and removing it from command line.

Perform the following:

vi /opt/bin/ipk

and type /wget until you would not see the command which is calling wget with parameter. See on screenshot marked with red color:

Now you can remove the ugly parameter and instead of each character specify spacebar. For this you can switch to insert mode : type “I” and remove character using Del and add space character using Space Bar. In the end it should look like this:

Exit vi and save the file by typing: twice “Esc” and then “:x”. You are done now, try to run ipkg and make sure that it does not fail. If you have something like “Bus Error” it means things are not done properly. But you can use my patched ipkg which works okay.

Now it’s time to setup the rest of config files and directories, and for this you can use my script.

Installing ipkg to /opt

An automated script has been developed to install ipkg on Tomato USB Mod firmware for RT-N16. Before launching this script make sure you have performed mounting of USB flash drive to /opt. If you did not do this, read article from the beginning.

Now, connect to router via ssh and perfom the following:

cd /opt


chmod +x ./


This should launch automated script to prepare ipkg structure and when it finishes the ipkg is supposed to work. Try to install wake on lan utility:

# ipkg install wakelan
Installing wakelan (1.1-2) to /opt/...
Configuring wakelan
Successfully terminated.

Have fun! See here the list of packages you can now install on your router: