Installing ipkg on Tomato USB for Asus RT-N16

It’s been quite a long time seems I’ve installed Oleg’s firmware and it was working very well. The version of firmware I was using for these 6 months is RT-N16- and you can download it here: (exact URL is )

Yesterday I’ve decided to upgrade to a latest Oleg firmware and I got a showstopper problem: my wi-fi stopped working, therefore clients were unable to connect and reseting router and rebooting did not help.

Having such severe problem with wi-fi I decided to give a try with Tomato or DD-WRT and see how it goes. Flashed Tomato and my wi-fi problem disappeared. Enabled printing support in Tomato WeUI interface and my printer works. Wow, this thing is really good.

If you wish to upgrade to Tomato Mod USB please download firmware at the official page: or at my blog here: (exact link for firmware file is: tomato-K26USB-1.28.9050MIPSR2-beta20-Ext.rar). See here how you can install alternative firmware on your router.

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:


This section will be filled up with users feedback once there will be some problems with script I’ve made. Hopefully this will be the only text in this section …



    • You can see list of packages here:

      I suppose you can install anything from that list, but to make it work it will take some extra time 🙂 For example, xmail – you have to configure and make tests as it is memory demanding application.

      I am willing to install xmail on RT-N16 as I don’t trust common mail providers – their policy usually allows to publish your emails after 2 months since you recieve them … So, settupping own mail server might be a good idea …

      • Thanks. Didn’t get the “their policy usually allows to publish your emails after 2 months since you recieve them” part; please elaborate. My Gmail account (not the one I use for on-line discussions/etc.) of 6.5 years gets almost no spam and there’s not a single mention of it in search engines.

        I’ll keep reading your blog and look forward to your future experiments with the Tomato USB f/w.


    • The same for me, actually:

      Filesystem 1K-blocks Used Available Use% Mounted on
      /dev/root 5632 5632 0 100% /
      tmpfs 63500 332 63168 1% /tmp
      devfs 63500 0 63500 0% /dev
      /dev/sda2 3414824 151292 3090068 5% /opt

      But free shows that the swap is used (I created 512 MB swap partition):

      total used free shared buffers
      Mem: 127000 24012 102988 0 3148
      Swap: 524280 0 524280
      Total: 651280 24012 627268

  1. Followed your guide, everything worked great. Thanks again.

    I couldn’t locate and install a “passwd” package so that I could change passwords for users added through “adduser”. Any idea how?

  2. My question is not related with ipkg but with Tomato.
    How to setup dual access on Tomato? WAN type is l2tp. After connecting to the Internet there is route to provider’s intranet in Route Table (something like mask gw WAN). The route is added by default, I did nothing for that. But dual access doesn’t work, there is no ping to provider’s resources.

    How to setup dual access using Tomato?

  3. Hello, and thank you for writing up such informative guides on both Oleg’s and TomatoUSB firmwares.
    My questions don’t pertain to ipkg, but it does refer to the 2 firmwares; Which of the two do you prefer? Is setting up a printer easier on TomatoUSB or on Oleg’s? Has TomatoUSB proven to be more stable or similar? I’ve been using Oleg’s firmware – upgrading to the newest one every week or 2 – and I’m thinking of changing to TomatoUSB.

    Once again, thank you.

  4. I’m using Tomato 1.27 (TeddyBear USB Mod) on my Asus WL-520GU and want to install ipkg so I can get oww (One Wire Weather) support on my router. Do you think your RT-N16 ipkg install script will work? Is there any reason to believe it is device-specific?


  5. Hi,

    Excellent article. Good work!

    Unfortunately it is not working for me. I think that in my system the xinetd is not running. How can I check if the xinetd service is running?

    Should the xinetd write something to xinetd.log?

    I am a total newbie with this, so I am sorry if my questions are simple/stupid.

  6. I have tried this procedure to install ipkg on an Asus WL-500GP-v2 running “Tomato Firmware v1.28.8748 ND USB Std”, and it appeared to work (the USB device appears as /dev/discs/disc0/part1 rather than /dev/sda1 etc), but when I run ipkg I get the error: “ipkg: can’t resolve symbol ‘mkdtemp'”

    Is that because there is something missing in the busybox environment?
    Any tips for debugging this?

  7. I have the Tomato (beta) Version 1.28 firmware on my Asus router. However, I am unable to get this working. I am using windows 7 64 bit and I do not know how to make a swap partition.

    • Steven: I have the Tomato (beta) Version 1.28 firmware on my Asus router. However, I am unable to get this working. I am using windows 7 64 bit and I do not know how to make a swap partition.

      Take a look at this tutorial: , more specifically, look at “PREPARE UBUNTU LINUX” section. You will have to install virtual box and ubuntu on your machine and then use gparted to create layout on drive.

      I guess, you can also find some utility under Windows to support ext3 and swap.

      • Volodymyr Shcherbyna,

        Volodymyr Shcherbyna,
        I followed the steps in the tutorial and everything turned out alright.

        root@unknown:/tmp/home/root# df
        Filesystem 1K-blocks Used Available Use% Mounted on
        /dev/root 5504 5504 0 100% /
        tmpfs 63476 128 63348 0% /tmp
        devfs 63476 0 63476 0% /dev
        /dev/sda2 3343200 71424 3101948 2% /opt
        However, when I get to the bazinga step.

        root@unknown:/tmp/home/root# mkdir /opt/bazinga
        root@unknown:/tmp/home/root# cd /opt/
        root@unknown:/opt# ls
        bazinga lost+found

        Is that meant to happen?

        And my last step also messed up.

        root@unknown:/opt# # ipkg install wakelan
        root@unknown:/opt# Installing wakelan (1.1-2) to /opt/.
        -sh: syntax error: unexpected “(”
        root@unknown:/opt# Downloading
        -sh: Downloading: not found
        root@unknown:/opt# Configuring wakelan
        -sh: Configuring: not found
        root@unknown:/opt# Successfully terminated.
        -sh: Successfully: not found

  8. Hi.

    Good tutorial.

    I’m however getting:
    root@tomato:/opt# ./
    Shell script to set up ipkg on Tomato Mod USB on Asus RT-N16 version
    Written by Volodymyr M. Shcherbyna,
    Comments, questions? Post them to

    Step 1: building directory structure …
    mkdir: cannot create directory ‘etc’: File exists
    mkdir: cannot create directory ‘bin’: File exists

    Step 2: making folders writable …

    Step 3: downloading config file for ipkg …

    Connecting to (
    wget: can’t open ‘ipkg.conf’: File exists

    Step 4: downloading and configuring ipkg …

    Connecting to (
    wget: can’t open ‘ipkg’: File exists

    Step 5: probing ipkg by issuing update…

    ./ipkg: can’t resolve symbol ‘glob’
    ./ipkg: can’t resolve symbol ‘glob’

    Step 6: everything done, trying to update

    ipkg: can’t resolve symbol ‘glob’
    root@tomato:/opt# uname -a
    Linux tomato #1 Wed Jan 6 13:45:49 EST 2010 mips GNU/Linux
    root@tomato:/opt# df
    Filesystem 1K-blocks Used Available Use% Mounted on
    /dev/root 4288 4288 0 100% /
    devfs 63584 0 63584 0% /dev
    tmpfs 63584 168 63416 0% /tmp
    /dev/sda1 2001624 3220 1998404 0% /opt

    I’m thinking there is a libc issue or something missing, right?

  9. How can I learn about the directory/file structure in the rt-n16. I run win 7 32bit but I play with Linux and have been using a Live version of Ubuntu to learn Linux. I have a structure with so many sub-directories that I have a mess. I have been trying to install the spin down function but every time I think I have it and reboot everything disappears. Cleanly the flash memory is doing something!

    I got Tomato 1.28 installed, almost by accident, after trying for two days to do it. I am very pleased with that but the external usb drive noise is killing me. I just printed your instruction for ipkg as much for learning as for trying to install it. Until I can understand what goes on inside the hardware I’m wasting my time and getting very frustrated.

    If you could point me to a site, a book or something that would help me learn the rt-n16 I would be very grateful!


  10. At the beginning, you said “just enable /jffs and you have ipkg working” but I tried to use ipkg and got ipkg: not found. I don’t mind using jffs for optware because I’m only after the hplip package in the first place. Are you sure I don’t have to install optware to jffs first?

  11. Hi there, i have installed sane-backend as per instructions, but it turns out my printer/scanner (canon mp280) is not supported in sane-backends 1.0.22. But the 1.0.23git ( … ml#S-PIXMA) does support it.

    Is there any way to get the un-released sane-backends (1.0.23git) created into an ipkg?

    “bind failed (Address already in use (errno = 98)). service = saned”

Leave a Reply

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