Thursday, June 24, 2010

Software Installation on DD-WRT -- Part 1

One thing interesting about the router is its exotic hardware specification -- 400MHz processor, 32MB flash ROM, 64MB RAM and most important of all, a USB port. All these make the router a very versatile little Linux box with tons of capabilities. However, one thing might confuse non-experienced users is that, the CPU in the router is MIPS(MIPS in big-endian), while the popular Broadcom routers(such as Linksys WRT54G) are MIPSEL(MIPS in little-endian). I don’t want to go into technical detail here, but just remember, even both are MIPS, they’re different and prebuilt binary for Broadcom routers WILL NOT work on this WZR-HP-G300NH and other Atheros based devices.

Thanks to the OpenWrt guys, with some effort, we can now put the OpenWrt binary on this router and it will run as good as the popular “optware”.

In this tutorial, I'll guide you through the process and all software will be installed on USB disk though the Buffalo router has a gorgeous 32MB flash ROM. The reason is simple – the flash ROM jffs partition will NOT survive during a firmware upgrade and you definitely don’t want to reinstall everything again each time. Also, USB disk is much faster than internal flash.

This guide will also work with other USB enabled Atheros routers such as TP-LINK TL-WR1043ND, Linksys WRT160NL, D-LInk DIR-825 RevB and Netgear WNDR3700

  1. Prepare the USB disk
    Here we can use a USB flash drive or a USB hard drive and the drive must be preformatted to ext2 or ext3(recommended) before plugging into the router.
    Any Linux live CD should do the trick and I personally recommend GParted, which can be installed in CD or USB disk.

  2. Set up DD-WRT accordingly
    a. Turn on ssh.
    This is under Services->Service->Secure Shell. See the picture below. Then click “Apply Settings” at the bottom of the page.
    ssh-enable

    b. Set USB Support
    Under Services->USB tab. Will disable “Automatic Drive Mount” here. After that, click “Apply Settings”usb-enable

    c. Disable the jffs partition
    Under Administration->Management, disable “JFFS2 Support”. After that, click “Apply Settings”.

  3. Download WinSCP, PuTTY and prebuilt libraries
    WinSCP is used to copy file between PC and router and PuTTY is for router shell login. Both are freeware.
    Also, you’ll need some prebuilt OpenWrt libraries called lib.tar(thanks Luyi@DD-WRT forum check original discussion thread)
    Get it from DD-WRT forum(login required) or mirror site.

  4. Now plug in the USB drive and reboot the router.

  5. After rebooting, login the router with PuTTY.
    Fill in router’s IP(192.168.1.1 in most cases), left everything else on default(port 22 and Connection type SSH) and click “Open”.
    The login username is always root and password is the web password you set.

  6. Mount the USB drive
    Type the command in PuTTY window
    ls /dev/discs/disc0/
    and the result might look like this
    disc-partitions
    Now here is the tricky part. If you’re using a USB flash drive with only one partition, most likely, you will only see “disc” but not “part1” and “part2”. If you’re using a USB HDD with multi partitions you might expect an output similar to mine. Both are OK.

    If you see “disc” only, use the command line below to mount an ext3 USB drive to /mnt
    mount -t ext3 -o noatime /dev/discs/disc0/disc /mnt
    *Use mount -t ext2 /dev/discs/disc0/disc /mnt for ext2 drive

    For USB drive with multi partition, the command below will mount the first partition to /mnt. Adjust accordingly.
    mount -t ext3 -o noatime /dev/discs/disc0/part1 /mnt
    *Use mount -t ext2 /dev/discs/disc0/part1 /mnt for ext2 partition

  7. Now create and prepare necessary folders
    Type the commands below in PuTTY

    cd /mnt
    mkdir etc opt root
    touch optware.enable
    chmod 755 etc opt root
    mkdir opt/lib
    chmod 755 opt/lib
    cp -a /etc/* /mnt/etc/
    mount -o bind /mnt/etc /etc
    mount -o bind /mnt/opt /jffs

    So now we have a writable /etc and /jffs folders while they both reside in the USB drive. All other folders -- especially /bin, /usr and /sbin – will be left untouched to keep the change minimal. The /etc folder will also be handled with extra caution.

  8. Extract lib.tar and upload all files to router’s /jffs/lib folder by using WinSCP.
    Same as PuTTY, the username will always be root, the file protocol must be set to SCP. See the picture below
    winscp-login
    After that, ignore all warning messages and click “yes” all the way. You’ll see the file transfer Window then. Also please refer to DD-WRT Wiki if there is any other question.

    Now extract lib.tar(using WinRAR or 7Zip) and upload everything to router’s /jffs/lib folder.

    In the Putty window, run
    ls /jffs/lib
    to make sure all files are uploaded, then run
    chmod a+x /jffs/lib/*
    to set the properties.

  9. Install OpenWrt’s opkg
    Now in the PuTTY window, type

    cd /tmp
    wget http://downloads.openwrt.org/backfire/10.03/ar71xx/packages/opkg_513-2_ar71xx.ipk
    ipkg install /tmp/opkg_513-2_ar71xx.ipk

    After that, run the command to create the configuration file for newly installed opkg

    cat > /etc/opkg.conf << EOF
    src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/
    dest root /opt
    dest ram /tmp
    lists_dir ext /tmp/var/opkg-lists
    EOF

    Also notice the underlined /opt. In the future, all software will be installed to /opt folder in case some might still want to use internal flash. The /jffs folder is only necessary for initial setup.

  10. Set the startup script to make the changes take effect each time upon reboot
    Under DD-WRT’s web interface, Administration->Commands,  input the following command in the window then click “Save Startup”

    #!/bin/sh

    sleep 5
    #mount -t ext3 -o noatime /dev/discs/disc0/disc /mnt
    mount -t ext3 -o noatime /dev/discs/disc0/part1 /mnt
    #choose one for your drive, see Step #6

    sleep 2
    if [ -f /mnt/optware.enable ]; then
    mount -o bind /mnt/etc /etc
    mount -o bind /mnt/root /tmp/root
    mount -o bind /mnt/opt /opt
    else
    exit
    fi

    if [ -d /opt/usr ]; then
    export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib'
    export PATH='/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/sbin:/usr/sbin:/usr/bin'
    else
    exit
    fi
     

    Reboot to make the change take effect.

  11. Test opkg package system
    After reboot, login with PuTTY again, run

    export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib'
    export PATH='/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/sbin:/usr/sbin:/usr/bin'
    opkg update

    to check if opkg(the OpenWrt’s variant of ipkg) is installed and working properly.
    Then install/upgrade some base libraries and the busybox utility

    opkg install libc
    opkg install libgcc
    opkg install uclibcxx
    opkg install libncurses

    opkg install busybox

Almost done! There’re still some work and fine tune left which will be covered in the next part.

92 comments:

Zach said...

Thanks so much for posting this blog! I have the exact same router and know exactly squat about linux, needless to say "Optware the right way" was not right for me!

Im fine until I get to installing opkg, here is the error i'm getting:


DD-WRT v24-sp2 std (c) 2010 NewMedia-NET GmbH
Release: 06/12/10 (SVN revision: 14594)

DD-WRT login: root
Password:
==========================================================

____ ___ __ ______ _____ ____ _ _
| _ \| _ \ \ \ / / _ \_ _| __ _|___ \| || |
|| | || ||____\ \ /\ / /| |_) || | \ \ / / __) | || |_
||_| ||_||_____\ V V / | _ < | | \ V / / __/|__ _|
|___/|___/ \_/\_/ |_| \_\|_| \_/ |_____| |_|

DD-WRT v24-sp2
http://www.dd-wrt.com

==========================================================


BusyBox v1.13.4 (2010-06-12 04:19:42 CEST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

root@DD-WRT:~# export LD_LIBRARY_PATH='/jffs/lib:/jffs/usr/lib:/lib:/usr/lib'
root@DD-WRT:~# export PATH='/jffs/bin:/jffs/usr/bin:/jffs/sbin:/jffs/usr/sbin:/b
in:/sbin:/usr/sbin:/usr/bin'
root@DD-WRT:~# ipkg install /jffs/opkg_528-1_ar71xx.ipk
ERROR: File not found: //usr/local/lib/ipkg/lists/whiterussian
You probably want to run `ipkg update'
ERROR: File not found: //usr/local/lib/ipkg/lists/non-free
You probably want to run `ipkg update'
ERROR: File not found: //usr/local/lib/ipkg/lists/backports
You probably want to run `ipkg update'
/bin/ipkg: line 1184: sort: not found
tar: invalid gzip magic
tar: short read
ipkg_install_file: ERROR unpacking control.tar.gz from /jffs/opkg_528-1_ar71xx.i
pk
root@DD-WRT:~#

PLEASE help, I've been all over the internet and your blog is the only place that's made any sense =(

leo.d said...

the error message indicating "You probably want to run `ipkg update'" is as expected. Yours looks like the opkg_528-1_ar71xx.ipk file is corrupted. Can you double check if the md5sum is correct by running "md5sum /jffs/opkg_528-1_ar71xx.ipk".

you can also try to get another opkg by
cd /jffs
wget http://downloads.openwrt.org/backfire/10.03/ar71xx/packages/opkg_513-2_ar71xx.ipk
ipkg install /jffs/opkg_513-2_ar71xx.ipk

leo.d said...

also the two "export ..." commands before "ipkg install ..." is actually not necessary, i just removed it. can you try that again? and if you've put the startup script and rebooted, then everything will be on /opt folder, in that case, run

ipkg install /opt/opkg_528-1_ar71xx.ipk -d /opt

Zach said...

ok, while trying to find a solution myself, I came across this post: http://www.dd-wrt.com/phpBB2/viewtopic.php?t=74424&sid=16f46dc7136f653e227c64f849305d15

I ran the following commands in telnet:
wget -O /tmp/uclibcxx_0.2.2-3_ar71xx.ipk http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/uclibcxx_0.2.2-3_ar71xx.ipk
wget -O /tmp/openwrt-ar71xx-rootfs.tar.gz http://downloads.x-wrt.org/xwrt/kamikaze/snapshots/ar71xx/default/openwrt-ar71xx-rootfs.tar.gz
tar -xvzf /tmp/openwrt-ar71xx-rootfs.tar.gz -C /opt
ipkg -d /opt install /tmp/uclibcxx_0.2.2-3_ar71xx.ipk

echo -e "src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/
dest root /opt
dest ram /tmp
lists_dir ext /tmp/var/opkg-lists" > /opt/etc/opkg.conf
echo -e "#!/bin/sh
export IPKG_INSTROOT=/opt
/opt/bin/opkg -f /opt/etc/opkg.conf \$1 \$2" > /opt/bin/ipkg-opt
chmod 755 /opt/bin/ipkg-opt
mount --bind /opt/ /jffs/
export LD_LIBRARY_PATH=/opt/lib:/opt/usr/lib:/lib:/usr/lib:/jffs/lib:/jffs/usr/lib:/jffs/usr/local/lib:/mmc/lib:/mmc/usr/lib

and then continued the directions from your blog. It LOOKS like everything went ok, but I have no idea what most of those do. Did I screw something up?

I was able to continue to the next page in your blog and successfully have a red and blue command prompt. But I have no idea how to use vi or nano, i'm pretty sure the file was created but the contents looked weird while I was typing, almost like it was writing over the lines w/ grey backgrounds. how do i view the contents of the file to be sure, and how do i undo any damage those other commands may have done? sorry to ramble, i just have no idea what i'm doing =( Thank you so much for your help!

leo.d said...

if it works then it's ok. but make sure you hava a /etc/opkg.conf. I think as long as you have done part2 and also the startup script in part1, then it should be fine as all other settings u used are not permanent.

to check file contents, run:

cat /path/to/filename

like

cat /mnt/root/.profile

vi is a little steep but nano should be easy, just follow the onscreen direction.

Anonymous said...

One suggestion: please post what the resulting display should show once we run the command. It's hard to follow if we don't know if the command run correctly or not.

Other than that, great info!

Anonymous said...

Hello.
Great guide. I installed the DD-WRT because i think it is more user friendly than Open-WRT.
Though I have some strange errors.
I want to install a HD with 3 partitions (1 reserved for software installation). I followed your steps to connect the disc and when I type the "mount -t ext2 /dev/discs/disc0/part1 /mnt" command I have an error like "wrong parameter" (sorry, I don't have the router right now and I don't remember the right error).

Another strange thing. If I try "mkdir" I have a "Read only system" error. Then I do the "mount -n -o remount,rw /" command. Now if I try "mkdir" I have the error "Operation not permitted"

Can you help me with those errors. I spent much time and I don't resolve anything.
Thank you very much.

Anonymous said...

root@DD-WRT:/jffs# cd /tmp
root@DD-WRT:/tmp# wget http://downloads.openwrt.org/backfire/10.03/ar71xx/packag
es/opkg_513-2_ar71xx.ipk
Connecting to downloads.openwrt.org (78.24.191.177:80)
wget: can't open 'opkg_513-2_ar71xx.ipk': File exists
root@DD-WRT:/tmp# ipkg install /tmp/opkg_513-2_ar71xx.ipk
ERROR: File not found: //usr/local/lib/ipkg/lists/whiterussian
You probably want to run `ipkg update'
ERROR: File not found: //usr/local/lib/ipkg/lists/non-free
You probably want to run `ipkg update'
ERROR: File not found: //usr/local/lib/ipkg/lists/backports
You probably want to run `ipkg update'
/bin/ipkg: line 1184: sort: not found
Unpacking opkg...Done.
Configuring opkg...Done.


Please i need help

Crush said...

@Anon: I experienced this same issue, but continued with this guide, part 2, and the Transmission guide without fail. I read that a lot of people would have this issue, but some would suggest they keep going anyways as the errors wouldn't affect their install.

@leo.d: Do you know of a way to safely unmount the HDD? I have an issue with my router (even before doing this guide) of my router losing it's WAN and the best way to (unfortunately, temporarily) remedy it is to unplug the modem and router and then plug them in a minute a part from one another. I am afraid though that if I just unplug the router that the filesystem on the HDD will get messed up.

Zach said...

@Crush: do you have the g300nh? If so, mine does this too and I can't find anything in the logs. I'm running OpenWRT now but it could be the same issue

Crush said...

Yes, I am using that model. Lots of searching shows this happens for a lot of different routers with no common solution. A lot of the time it has to do with someone ticking something that they shouldn't have in a rush to set things up, but I have 30-30-30'd my router and started from scratch so many times just doing the router user/pass and wireless information. I am actually in the middle of setting this stuff up again. So far it has been ok, if it starts happening after this, I am going to start suspecting the HDD and/or optware/this guide have something to do with it.

Do you mean you are running the OpenWRT firmware as opposed to the DD-WRT?

iddqd said...

Trying to get opkg working on a TP-Link TL-WR1043ND and running into a similar issue as Anon. My output is:

root@DD-WRT:/tmp# ipkg install /tmp/opkg_513-2_ar71xx.ipk
ERROR: File not found: //usr/local/lib/ipkg/lists/whiterussian
You probably want to run `ipkg update'
ERROR: File not found: //usr/local/lib/ipkg/lists/non-free
You probably want to run `ipkg update'
ERROR: File not found: //usr/local/lib/ipkg/lists/backports
You probably want to run `ipkg update'
/bin/ipkg: line 1184: sort: not found

So without the:
Unpacking opkg...Done.
Configuring opkg...Done.

So kinda stuck there =/ Any ideas?

Isanderthul said...

I noticed that the file etc/opkg.conf was not being created, the script given was wrong for me,
cat > /etc/opkg.conf << EOF
should rather be
cat > etc/opkg.conf << EOF

Isanderthul said...

it would be good to note that only one partition is in use with this method, so if you have formatted other partitions on the drive like recommended on the ddwrt forums, you will waste that space.

Anonymous said...

Could there be a clear link to obtain the lib.tar file? Searched Openwrt without joy.

You might also recommend a partitioning scheme prior to installation.

I've repartitioned several times for various installation guide and each has slightly different requirements.

For instance, Optware the Right Way (wrong) has no /mnt.

TEDDY said...

hi, i got a problem with step 6, why it always say "ls /dev/discs/disc0/ : no such file or directory", i had tried use putty both win 7 & ubuntu, and try hdd box and usb flash so it always stuck with notice, could someone help me plzz !!!

dd-wrt fan said...

Can't seem to install kernel modules through optware this way. uname -a reports Linux DD-WRT 2.6.24.111 and I can'r find any ipkg or opkg sources that match. I get:

"insmod: cannot insert 'usbserial.ko': invalid module format"

when trying to insert any modules through ipkg. Any ideas where I can find an ipkg or opkg source for DD-WRT v24-sp2 on the g300NH?

ccdoggy said...

From what i hear This will NOT work on any dd-wrt newer then 14929. They updated the kernel and so opkg and all associated stuff needs to be updated to support it.

ccdoggy said...

ignore my above comment. it still works great!

Nathan Black said...

Teddy: currently the USB drives on WNDR3700 are under /dev/sda* . for me it's /dev/sda1, so you're commands that involve /dev/discs/blahblahblah shoudl all reference /dev/sda1. So my mount command is:

mount /dev/sda1 /mnt

I'm using a flash drive with ext2, so ext3 drives would be:

mount -t ext3 /dev/sda1 /mnt

etc... type "mount --help" for more info.

Hope that helps.

rkistar said...

hi all,

when i reboot my router (wndr3700), and i want to update list, i have a bug.

root@router:/# opkg update
opkg: can't resolve symbol 'glob64' in lib 'opkg'.

Betino said...
This comment has been removed by the author.
Betino said...

I have a P-Link TL-WR1043ND and I've managed to install opkg, but it ran only one or two commands (opkg list and an opkg install libc). After that I always get the fallowing error:

root@747 /jffs $ opkg list
opkg: can't resolve symbol 'glob64' in lib 'opkg'.

I tried to reinstall it, but no luck.
Do you have any idea?

P.S. Great blog!

Anonymous said...

Hi everyone,
I tried this guide on my dir825 today and i am stuck on step 9.
When i tried to install opkg i got the following:
root@DD-WRT:/tmp# ipkg install /tmp/opkg_513-2_ar71xx.ipk
ERROR: File not found: //usr/local/lib/ipkg/lists/whiterussian
You probably want to run `ipkg update'
ERROR: File not found: //usr/local/lib/ipkg/lists/non-free
You probably want to run `ipkg update'
ERROR: File not found: //usr/local/lib/ipkg/lists/backports
You probably want to run `ipkg update'
/bin/ipkg: line 1184: sort: not found

Unpacking opkg...Done.
Configuring opkg...Done.
I tried to ignore it but the config files is not create and opkg is not installed so i can not continue.
How can i solve this??
Any help is appreciated.

Anonymous said...

Just a quick question,
Is the samba swat interface installed by the opkg command??

HeavyP said...

I also have some problem running opkg update so I followed Zach's comment and it works like a charm.

I also have no idea what I'm doing but it just works.

jfaubin said...

i have installed openswan and other service. when i try to start with /opt/etc/init.d/ipsec start
I receive this error:
/bin/sh: can't open /etc/rc.common
it's normal because this file is on /opt/etc.
How i use a service with: /opt/etc? Normally this system use /etc and not /opt/etc
Please help me

Anonymous said...

opkg_conf_init: Couldn't stat /etc/opkg.conf: No such file or directory

cannot create file /etc/opkg.conf: Read-only file system

help?

Anonymous said...

Hi everyone,
I tried this guide on my dir825 today and i am stuck on step 9.
When i tried to install opkg i got the following:
root@DD-WRT:/tmp# ipkg install /tmp/opkg_513-2_ar71xx.ipk
ERROR: File not found: //usr/local/lib/ipkg/lists/whiterussian
You probably want to run `ipkg update'
ERROR: File not found: //usr/local/lib/ipkg/lists/non-free
You probably want to run `ipkg update'
ERROR: File not found: //usr/local/lib/ipkg/lists/backports
You probably want to run `ipkg update'
/bin/ipkg: line 1184: sort: not found

Unpacking opkg...Done.
Configuring opkg...Done.
I tried to ignore it but the config files is not create and opkg is not installed so i can not continue.
How can i solve this??
Any help is appreciated.
October 9, 2010 11:31 AM

They guy above has the same issue as it happened to me. I am now using the Official Buffalo dd-wrt firmware. So any recommendations on this plz?

Anonymous said...

Hi all,
The same problem for me , i installed also transmission after this, and it work fine, with samba problem.
Please, can you make at all-in-one script for install optware latest-transmission and samba3 all upgradable and configurable , such that of wrt160nl.org ?
I used also this , and it work for this router
Sorry for my bad english

Anonymous said...

same here (netgear WNDR3700)

k said...

Hi,

A while ago I used this guide:
http://g300nh.blogspot.com/2010/06/software-installation-on-dd-wrt-part-1.html
and installed opkg, nano, and samba on my dir825 running 15437.
Today I ran the command opkg install libc to check for updates and it installed libc 0.9.3-60 on my router.

After that, everything breaks. nano returns xterm errors, swap dies, samba fails to start, and I cant install any packages because wget returns 255.

Is there any way to fix this???

Any help would be very very very appreciated!!!!!

Anonymous said...

[quote]
I have a P-Link TL-WR1043ND and I've managed to install opkg, but it ran only one or two commands (opkg list and an opkg install libc). After that I always get the fallowing error:

root@747 /jffs $ opkg list
opkg: can't resolve symbol 'glob64' in lib 'opkg'.
[/quote]

I have the same problem... Any ideas how to resolve this?

ccdoggy said...

DO NOT INSTALL libc from opkg!!!

its an updated version that causes all apps that use that library to fail.

just re-copy it from the lib.rar file into the directory again using SCP if you happened to run 'opkg install libc'

Anonymous said...

I skippked the following steps
>opkg install libc
>opkg install libgcc
>opkg install uclibcxx
>opkg install libncurses
>opkg install busybox

since cdoggy said something about the C runtime library from opkg is somehow broken.


I then did
>opkg install nano
which succeeds but then executing nano causes a segmentation fault. I can only guess this is due to nano being linked against the libc I didn't install.

I assume all the opkg packages are linked against that libc, which would make opkg pretty useless... No ?

Anonymous said...

[quote]
just re-copy it from the lib.rar file into the directory again using SCP if you happened to run 'opkg install libc'
[/quote]

emmm... Which directory exactly? :hmmm:

ccdoggy said...

Scratch that.

USE THIS LOCATION IN THE opkg.conf FILE

http://downloads.openwrt.org/backfire/10.03.1-rc3/ar71xx/packages/


not the one listed on the site. i just had to install everything and i could not get it to work with the original repository location. if you have installed apps, remove them change this web-address in the /etc/opkg.conf file and then go ahead. basically its a older repository as the new one is causing us problems.

Anonymous said...

thanks a lot ccdoggy. swapped the location to
http://downloads.openwrt.org/backfire/10.03.1-rc3/ar71xx/packages/ in my opkg.conf file and just tried nano and tcpdump, both packages worked.

Alex Atkin UK said...

Is ext3 really recommend if using a slow microSD card for storage? I was under the impression ext3 just causes more writes so ext2 is better for flash, ext3 being better for a HDD.

Also, would it perhaps be recommended to have a 128MB swap partition on there just in case RAM gets tight running all this extra stuff?

With that consideration, would there be enough improvement in getting a Samsung Plus Class 6 microSD card over my old Sandisk microSD card as I wouldn't want swapping I/O to stall routing.

This is all very new to me as I have been using Linux on the PC for years but never dabbled with DD-WRT as the routers it could be used on were expensive. Plus I really need my router to "just work" but I also hate the idea of it idling when it could be doing something useful.

Paul said...

I used http://downloads.openwrt.org/backfire/10.03.1-rc3/ar71xx/packages/ for my /etc/opkg.conf file and there are no libc issues. Conf file is as follows:

src/gz snapshots http://downloads.openwrt.org/backfire/10.03.1-rc3/ar71xx/packages/
dest root /opt
dest ram /tmp
lists_dir ext /tmp/var/opkg-lists

Good luck to other DD-WRT users out there!

Landon said...

This no longer works you can mount /dev/discs/disc0/disc /mnt it /dev/discs doesnt exist in DDWRT anymore so what are the new commands

gripen40k said...

@Landon:
You'll want to use "/dev/sda#", where # is the number of your disk ("ls /dev" to find out).

Once mounted you could always do a "df -h" to double check it's the right one.

Anonymous said...

Hey maybe you can write shell script what will install opkg ?

RoadRunnerQleap said...

Has anyone figured out what did the blogger refereed to by saying lib.tar?
There is no link to it and I could find it in openwrt.

Brandon said...

what version of dd-wrt are you running? std...big...mega? i'm trying to find a mega version of dd-wrt for this router, but i can't seem to find it anywhere! can you help possibly?

thanks a ton for creating this blog. GREAT WORK!

Alex Atkin UK said...

Okay I have a different issue now.

I had all this configured on my router but it was randomly rebooting. I couldn't figure what it was until I happened to try with the USB stick removed.

Basically it seems stock DD-WRT software was using some of the newer libraries as the instant I removed the extra library paths from the startup script my router was stable again. Anyone else experienced this?

Greg said...

Doesn't work for me either.

I try to update opkg and get:
opkg: '/opt/lib/libgcc_s.so.1' is not an ELF executable for MIPS
opkg: '/opt/lib/libc.so.0' is not an ELF executable for MIPS

Carpet Cleaning Las Vegas said...

I don't have any words to appreciate this post.....I am really impressed ....the person who created this post surely knew the subject well..thanks for sharing this with us.

Jack said...

I can't get this to work.

My etc/opkg.conf looks like the following:

src/gz http://downloads.openwrt.org/backfire/10.03.1- rc3/ar71xx/packages

dest root /opt
dest ram /tmp
lists_dir ext /tmp/var/opkg-lists

But everytime I try to run opkg update i get the following message:

Downloading /Packages.gz.
wget: not an http or ftp url: /Packages.gz
Collected errors:
* opkg_download: Failed to download /Packages.gz, wget returned 1.

Jack said...

opkg install seems working, but I can't get any packages get installed (e.g. ushare, samba):

root@Buffy:/jffs# opkg install ushare
Collected errors:
* opkg_install_cmd: Cannot install package ushare.
root@Buffy:/jffs#

Jack said...

Update: Works well now. Just repeated all steps from the beginning. Thanks.

Greg said...

I tried all the steps from the beginning...three times. Still no love.

How about someone puts all the right files into a zip file and we can copy that whole mess into ONE folder on the USB drive? Wouldn't that be quite a bit easier?

Or is there some sort of sadomasochistic pleasure Linux folks get out of torturing themselves and/or others with these hassles? ;-)

Move4less said...

First I would like to appriciate you for the valuable information sharing with us. Thanks for making informative blog.

Anonymous said...

I think this manual should be updated with new firmware because old one little bit have errors. Please author update it.

Greg said...

Right. There's conflicting information on which directory to use (10.03 or 10.03.l), where to put the correct info, and whether or not to use libc or not. Pick the wrong combination of directions and nothing works. Get lucky and combine the right set of directions from multiple posts and it might work. If not, reformat everything and start over. Have fun!

Greg said...

Okay, I finally was able to confirm Paul's comments above. Make ONLY this change to the original instructions:

I used http://downloads.openwrt.org/backfire/10.03.1-rc3/ar71xx/packages/ for my /etc/opkg.conf file and there are no libc issues. Conf file is as follows:

src/gz snapshots http://downloads.openwrt.org/backfire/10.03.1-rc3/ar71xx/packages/
dest root /opt
dest ram /tmp
lists_dir ext /tmp/var/opkg-lists

Thanks, Paul. On to Page 2.

Thien said...

When I run 'opkg update', I got following errors:
opkg: '/opt/lib/libgcc_s.so.1' is not an ELF executable for MIPS
opkg: '/opt/lib/libc.so.0' is not an ELF executable for MIPS
opkg: can't resolve symbol 'glob64' in lib 'opkg'.
Does anyone know how to fix errors? Thanks.

Greg said...

Best way to fix errors is to start completely over and follow the instructions to the letter, making sure you make the one change I noted above. And ONLY that one change.

Small errors may not show up until later. I had that problem one of the few times it took me to install mine.

Yegor said...

My Service > USB tab doesn't have ext2 /ext3 support option when I enable everything it just doesn't show up.
Why?
I use 15962 build.

Titus said...

Hi can you help me I get stuck at:

ipkg install /tmp/opkg_513-2_ar71xx.ipk
sort: can't resolve symbol '__fpending' in lib 'sort'.
Unpacking opkg...Done.
Configuring opkg...tar: can't open './bin/opkg': Read-only file system
Done.

Anton said...

Could You please tell me, what firmware is faster for G300NH, dd-wrt or "native" 1.76? I have Buffalo LS-XHL NAS, so I don't need nas or torrent features on router. My ISP uses "plain" DHCP connection (without PPTP/PPPoE, e.t.c). 50mb/sec - to external network, 100mb/sec to "local" resources.

Thank You in advance and please, excuse me for my bad English, it's because I'm Russian :)

Max Pierson said...

Thank you very much for putting this together every time I try to install a package, I get, for example:

root@Airstation root $ opkg install nano
opkg: can't resolve symbol 'lockf64' in lib 'opkg'.

I can't figure out that 'lockf64', it's killing me. Any ideas?

robert said...

same as above any hints this lockf64 is a pain

robert said...

try anything else after that i get

cat: can't handle reloc type 0x2f

Max Pierson said...

Got it working, start from the beginning, but use the location:
http://downloads.openwrt.org/backfire/10.03.1-rc3/ar71xx/packages/

as in cdoggy's comment above.

Anonymous said...

Hi Guys,
I got issue at the copy etc folder line

cp: cannot create symlink '/mnt/etc/cron.d': Operation not permitted
cp: cannot create symlink '/mnt/etc/freeradius/sites-enabled/control-socket': Operation not permitted
cp: cannot create symlink '/mnt/etc/freeradius/sites-enabled/default': Operation not permitted
cp: cannot create symlink '/mnt/etc/freeradius/sites-enabled/inner-tunnel': Operation not permitted
cp: cannot create symlink '/mnt/etc/group': Operation not permitted
cp: cannot create symlink '/mnt/etc/hosts': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/teamviewer.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/teamviewer1.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/thunder5_see.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/thunder5_tcp.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/webmail_163.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/webmail_gmail.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/webmail_hinet.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/webmail_yam.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/yahoo_camera.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/yahoo_file.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/yahoo_login.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/yahoo_voice.pat': Operation not permitted
cp: cannot create symlink '/mnt/etc/nocat.conf': Operation not permitted
cp: cannot create symlink '/mnt/etc/nvram': Operation not permitted
cp: cannot create symlink '/mnt/etc/passwd': Operation not permitted
cp: cannot create symlink '/mnt/etc/resolv.conf': Operation not permitted
cp: cannot create symlink '/mnt/etc/snmp': Operation not permitted


Any thoughts?

Stefano said...

all right but for some pakages some problem like:


root@DD-WRT root $ opkg update
Downloading http://downloads.openwrt.org/backfire/10.03.1-rc4/ar71xx/packages/Packages.gz.
Inflating http://downloads.openwrt.org/backfire/10.03.1-rc4/ar71xx/packages/Packages.gz.
Updated list of available packages in /tmp/var/opkg-lists/packages.
root@DD-WRT root $ opkg install usbutils
Installing usbutils (0.90-1) to root...
Downloading http://downloads.openwrt.org/backfire/10.03.1-rc4/ar71xx/packages/usbutils_0.90-1_ar71xx.ipk.
Configuring usbutils.
/opt//usr/lib/opkg/info/usbutils.postinst: cd: line 2: can't cd to /usr/share
Connecting to www.linux-usb.org (216.34.181.97:80)
- 100% |*******************************| 434k 00:00:00 ETA
Done.
root@DD-WRT root $ lsusb
lsusb: cannot open "/usr/share/usb.ids", No such file or directory


the same with pcscd ...

Anonymous said...

Because of my configuration, I used this for my mount command: mount /dev/sda3 /mnt

Also, opkg install libc appears to run but every command after it throws a can't handle reloc type 0x2f error. I'm going to start from scratch and see if I can't just not install that.

Zooch said...

I modified the startup script so it would mount the USB Flash drive at the /mnt point regardless of how many USB Storage devices are present. It only uses the built in busybox tools.


#!/bin/sh
for I in `/usr/bin/find /sys/block/s*/device/vendor` ; do
DNAME=`dirname ${I}`
VENDOR=`cat ${I}`
MODEL=`cat ${DNAME}/model | sed -e 's/ *$//'`
if [ $VENDOR == "Verbatim" ] && [ "$MODEL" == "TUFF N TINY" ]; then
NAME=`dirname ${DNAME}`
DISK=`basename ${NAME}`
DEV=`cat ${NAME}/${DISK}1/dev`
for M in `find /dev/discs/ -name part1 -follow` ; do
TDEV=`ls -l $M | tr -s ' ' ' ' | cut -d " " -f 5,6 | tr -s ', ' ':'`
if [ $TDEV == $DEV ] ; then
mount -t ext3 -o noatime ${M} /mnt
break
fi
done
fi
done


if [ -f /mnt/optware.enable ]; then
mount -o bind /mnt/etc /etc
mount -o bind /mnt/root /tmp/root
mount -o bind /mnt/opt /opt
else
exit
fi

if [ -d /opt/usr ]; then
export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib'
export PATH='/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/sbin:/usr/sbin:/usr/bin'
else
exit
fi


You will need to change the Verbatim and TUFF N TINY text to whatever matches your USB storage device.

find /sys/block/s*/device/vendor
will list all the Storage devices. cd into each directory listed and
cat vendor
cat model
will give you the information needed for this script.

Anonymous said...

Gents, try this guide: http://www.dd-wrt.com/phpBB2/viewtopic.php?t=86912

It's more convenient.

LMrt said...

many trackers don't allow transmission 2.20
you can install 2.21 from the repository
http://gallinaro.org/openwrt/Branch/ar71xx_25480/packages/
just replace the old link in /etc/opkg.conf with this new one and then
opkg remove transmission-daemon transmission-web
and then
opkg update
and then
opkg install transmission-daemon transmission-web

and wah-lah! amazingnesss

Javier said...

Im Getting this error

root@StrongVPN:~#
root@StrongVPN:~# ls /dev/sda*
/dev/sda /dev/sda1 /dev/sda2
root@StrongVPN:~# mount -t ext3 -o noatime /dev/sda2 /mnt
mount: mounting /dev/sda2 on /mnt failed: No such device
root@StrongVPN:~#

Seumas said...

When I try the ipkg command in step #9, I get

ipkg install /tmp/opkg_513-2_ar71xx.ipk
/bin/ipkg: line 1161: can't open /opt/etc/ipkg.conf: no such file

Did I miss a step? My router has nothing under /opt ...

Anonymous said...

I am getting this result when testing , step 11.


root@DD-WRT:~# export LD_LIBRARY_PATH='/opt/lib:/opt/usr/lib:/lib:/usr/lib'
root@DD-WRT:~# export PATH='/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/
sbin:/usr/sbin:/usr/bin'
root@DD-WRT:~# opkg update
Collected errors:
* opkg_conf_parse_file: /etc/opkg.conf:1: Ignoring invalid line: `src/gz snapsh ots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/ dest root /opt

José I. Monreal said...

leo.d I have followed the tutorial, but I ran into this problem wich I dont know what to do,

//usr/local/lib/ipkg/lists/backfire
You probably want to run `ipkg update'
/bin/ipkg: line 1184: sort: not found
mkdir: cannot create directory '///usr/local/lib/': Read-only file system

ipkg update
mkdir: cannot create directory '//usr/local/lib/': Read-only file system

On the first Read-only file system I understood that /usr should be mounted too, but in the tutorial doesnt say so.

How should I proceed?

create a folder /mnt/usr and mount it as /usr? or what?

Please let me know,
Thanks.

Mathew H said...

Like all these guides followed it word for word but of course it does not work

Brian S said...

Mmmmm yup had the same experience as Mathew H very frustrating considering I bought this to enable NAS off a usb SATA 160 gb drive

Anonymous said...

I had issues with these instructions at first. For no apparent reason, I decided to change the usb drive mount path from /mnt to /opt. I highly advise others not to deviate from the author's selected paths.

After an hour or so, I grabbed a new usb drive, carefully followed the instructions again from the top, and it almost worked. I had to change the first line in /etc/opkg.conf to read (without the quotes) : "src/gz snapshots http://downloads.openwrt.org/backfire/10.03.1-rc3/ar71xx/packages"

After I did that, I didn't install any of the packages at the end of the article, but did install nano, screen, busybox, and samba3 all without any issues.

I'm curious to see how things will go in the next week or two. A reboot may break some things, I may install some bad program, or it could continue to work wonderfully.

Be sure to do the first few steps from his next tutorial on this. It was key to get the root shell environmental variables set.

Anonymous said...

ushare 17201

#!/bin/sh

mkdir /mnt/opt
cp -a /etc/ /mnt/opt/
cp -a /bin/ /mnt/opt/
cp -a /lib/ /mnt/opt/
cp -a /usr/ /mnt/opt/
cp -a /tmp/ /mnt/opt/
cp -a /jffs/ /mnt/

mount /mnt/opt/etc /etc
mount /mnt/opt/bin /bin
mount /mnt/opt/lib/ /lib
mount /mnt/opt/usr/ /usr
mount /mnt/opt/tmp/ /tmp
mount /mnt/jffs/ /jffs

df -h

cp -a /mnt/ipk/ipkg.conf /etc/

cp /bin/ipkg /bin/ipkg.orig
cat /bin/ipkg.orig |sed -e "s/--passive-ftp //" > /bin/ipkg

ipkg update
ipkg install coreutils-sort
ipkg install opkg
ipkg install clib

opkg update
opkg install --force-space ushare

cp /mnt/ipk/ushare.conf /etc/

ushare &

Alexander Furer said...

Thanks for the detailed guidelines.
Should I mount EVERY partition in step 10 ?
I'm planing to have 2 partitions :
ext3 for opt and ntfs for media files (transmission should store torrents here and this partition should be accessible by Win machines).
How do I auto-mount NTFS partition ?
Thanks a lot

Felipe 'chronos' Prenholato said...

@AlexanderFurer ...
Make this partition ext3 or ext2, than use http://sourceforge.net/projects/ext2fsd/ to read ext2/ext3 on windows when you need it.

Anonymous said...

Had some errors... most notably when I got to step 11 above.

I started over at step 7... ignoring errors about directories I created the first time through or deleting and recreating files/folders as I went. Also changed a couple paths for the latest software version (2011-Dec-21 Backfire Interim Release 1 Final - version 10.03.1). Everything worked this time. Thought I would share the changes I made in case anyone has similar issues.

Under step 9, do the following for the latest version:
cd /tmp
wget http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages/opkg_576-2_ar71xx.ipk
ipkg install /tmp/opkg_576-2_ar71xx.ipk

Ignored the errors in this response:
ERROR: File not found: //usr/local/lib/ipkg/lists/whiterussian
You probably want to run `ipkg update'
ERROR: File not found: //usr/local/lib/ipkg/lists/non-free
You probably want to run `ipkg update'
ERROR: File not found: //usr/local/lib/ipkg/lists/backports
You probably want to run `ipkg update'
/bin/ipkg: line 1184: sort: not found
Unpacking opkg...Done.
Configuring opkg...Done.

Configuration File:
cat > /etc/opkg.conf << EOF
src/gz snapshots http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages/
dest root /opt
dest ram /tmp
lists_dir ext /tmp/var/opkg-lists
EOF

vbrtrmn said...

For anyone getting errors like below... the simple fix is to change the partition on the USB drive to ext3 rather than FAT32. FAT32 does not support permissions or symlinks.

Windows and OSX don't have native ext3, you'll need to do a bit of googling to figure it out. Sorry, I don't know off-hand otherwise I'd post links.

ERRORS BELOW OCCUR ON FAT32 PARTITIONED USB DRIVES

cp: cannot create symlink '/mnt/etc/cron.d': Operation not permitted
cp: cannot create symlink '/mnt/etc/freeradius/sites-enabled/control-socket': Operation not permitted
cp: cannot create symlink '/mnt/etc/freeradius/sites-enabled/default': Operation not permitted
cp: cannot create symlink '/mnt/etc/freeradius/sites-enabled/inner-tunnel': Operation not permitted
cp: cannot create symlink '/mnt/etc/group': Operation not permitted
cp: cannot create symlink '/mnt/etc/hosts': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/teamviewer.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/teamviewer1.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/thunder5_see.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/thunder5_tcp.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/webmail_163.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/webmail_gmail.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/webmail_hinet.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/webmail_yam.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/yahoo_camera.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/yahoo_file.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/yahoo_login.pat': Operation not permitted
cp: cannot preserve ownership of '/mnt/etc/l7-protocols/protocols/yahoo_voice.pat': Operation not permitted
cp: cannot create symlink '/mnt/etc/nocat.conf': Operation not permitted
cp: cannot create symlink '/mnt/etc/nvram': Operation not permitted
cp: cannot create symlink '/mnt/etc/passwd': Operation not permitted
cp: cannot create symlink '/mnt/etc/resolv.conf': Operation not permitted
cp: cannot create symlink '/mnt/etc/snmp': Operation not permitted

jeff said...

Can someone point me to some idiot proof directions to get optware and eventually pptp server working on Tomato Firmware v1.28.7496 MIPSR2-Toastman-VLAN-RT K26 USB VPN on an e3000. THus far none of the directions I have will load optware. I get bad elf and/or no ipkg with what I've tried thus far...

Andrew Vandever said...

I have the same problem as Yegor...no ext3 option on the usb tab. I'm running DD-WRT v24-sp2 (03/19/12) std - build 18777 on a DIR-825.

Andrew Vandever said...

When I auto-mount, it works fine. Weird.

Andrew Vandever said...

Just as a final follow-up, I'm not letting it do the auto-mount, then replacing the first mount line in the start-up script to do mount -o bind /tmp/mnt/sda_part1 /mnt. Everything from that point on is the same. What I don't fully understand is why I can't manually mount /dev/sda1 /tmp/mnt/sda_part1 (this is what's reported in /proc/mounts). Automounting must be doing some crazy foo.

Unknown said...

Thank you So MUCH!!! you are a life saver!!

Anonymous said...

When I tried

# mount -t ext3 -o noatime /dev/sda1 mnt/
mount: mounting /dev/sda1 on mnt/ failed: No such device

# lsmod |grep ext3
#
returns nothing!

But when I set in GUI Automatic Drive Mount=Enable

Voila! ext3 module support is installed
# lsmod |grep ext3
ext3 112416 1
jbd 32813 1 ext3
mbcache 4044 2 ext3,ext2

So now I can mount the system

Anonymous said...

Not working, how can i revert everything ?
Can you please create a script that will automate the process!

vbrtrmn said...

Packages file is corrupt at: http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/

Change:

opkg install libc
opkg install libgcc
opkg install uclibcxx
opkg install libncurses
opkg install busybox

To:

opkg install http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/libc_0.9.33.2-1_ar71xx.ipk
opkg install http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/libgcc_4.6-linaro-1_ar71xx.ipk
opkg install http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/uclibcxx_0.2.4-1_ar71xx.ipk
opkg install http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/libncurses_5.9-1_ar71xx.ipk
opkg install http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/busybox_1.19.4-7_ar71xx.ipk

vbrtrmn said...

Also .. All the packages in that path total up to 251M, as flash drives are now so cheap, I wound up just downloading the entire archive to my flash drive, instead of messing around with a somewhat broken archive.

Post a Comment