Buffalo WZR-HP-G300NH additional packages environment setup (ddwrt)


Assuming you’ve properly configured and initialized your jffs filesystem on your Buffalo WZR-HP-G300NH running the DD-WRT firmware, here’s the instructions to set-up the root filesystem (it needs its own, as the main root is not writable) and its package manager.


Creating root and installing the package manager

Download a compatible rootfs and install it in /jffs

cd /jffs
wget http://downloads.openwrt.org/snapshots/trunk/ar71xx/openwrt-ar71xx-generic-rootfs.tar.gz -O - | tar -zxf -

Download the opkg package manager which allows reconfiguring paths
wget "http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/opkg_*.ipk"
ipkg -d /jffs/ install opkg_*.ipk

Alternative 1 – relocated

Create your opkg configuration (using echo to allow copy/paste without switching to vi)
echo "src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/" > /jffs/etc/opkg_relocated.conf
echo "dest root /jffs" >> /jffs/etc/opkg_relocated.conf
echo "dest ram /tmp" >> /jffs/etc/opkg_relocated.conf
echo "lists_dir ext /jffs/var/opkg-lists" >> /jffs/etc/opkg_relocated.conf

You now have a second root installed in /jffs with its package manager, but we need to fix runtime binaries and libraries paths.
Create the setup script in your jffs root:
echo "export LD_LIBRARY_PATH=/jffs/lib:/jffs/usr/lib:/lib/:/usr/lib" > /jffs/setup.relocated
echo "export PATH=/jffs/bin:/jffs/sbin:/jffs/usr/sbin:/jffs/usr/bin:/bin:/sbin" >> /jffs/setup.relocated
echo "alias opkg='opkg -f /jffs/etc/opkg_relocated.conf'" >> /jffs/setup.relocated
chmod +x /jffs/setup.relocated

Initialize your environment when you need to use it
. /jffs/setup.relocated

Alternative 2 – chroot’ed

Here’s a better alternative relying on chroot, but needs to have completed alternative 1′s steps first. (or you won’t be able to install chroot)

Install chroot

opkg install chroot

Create the setup script for this configuration


echo "BIND_DONE=\`mount | grep /jffs/proc\`" > /jffs/setup.chroot
echo "if [ -z \"\$BIND_DONE\" ]; then for fs in dev sys mnt proc ; do mount --bind /\$fs /jffs/\$fs ; mount --bind /tmp/var /jffs/tmp/ ; done ; fi" >> /jffs/setup.chroot
echo "mkdir /var/lock" >> /jffs/setup.chroot
echo "/jffs/usr/sbin/chroot /jffs" >> /jffs/setup.chroot
chmod +x /jffs/setup.chroot

Create a regular opkg configuration to make it work inside chroot

echo "src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/" > /jffs/etc/opkg.conf
echo "dest root /" >> /jffs/etc/opkg.conf
echo "dest ram /tmp" >> /jffs/etc/opkg.conf
echo "lists_dir ext /var/opkg-lists" >> /jffs/etc/opkg.conf
rm /jffs/etc/opkg/xwrt.conf ; ln -s /etc/opkg.conf /jffs/etc/opkg/xwrt.conf
cp /etc/resolv.conf /jffs/etc/resolv.conf

Initialize your environment when you need to use it
. /jffs/setup.chroot

Finally

don’t forget to fetch the packages list:

opkg update
You can now install any package you want.

7 Responses - Add Yours+

  1. Mueller says:

    Hey, I followed your tutorial on my WZR-HP-G300NH, but after running . /jffs/setup.relocated, WGET cannot work. It seems WGET is no longer an integrated command, hence everything cannot install.

    Please help.

    • Francois says:

      You have wget in both /usr/bin/ and /jffs/usr/bin/, so /jffs/usr/bin/wget should work.
      I think you want to use the /usr/bin/ (ddwrt’s one) by default, then you need to change the library search path accordingly:
      export LD_LIBRARY_PATH=/jffs/lib:/jffs/usr/lib:/lib:/usr/lib
      I’ll update instructions accordingly.

  2. Mueller says:

    I had changed the path to “export LD_LIBRARY_PATH=/jffs/lib:/jffs/usr/lib:/lib:/usr/lib” in setup.relocated under /jffs, but it still doesn’t work. Wget cannot work.

  3. Mueller says:

    Maybe I haven’t made it clear. I use Putty to connect with G300NH. Under the root, wget works well. After executing “. /setup.relocated”, wget won’t work anymore. It’ll prompt “-sh: wget: not found”.

    Because wget cannot work, all installations won’t be possible. All will end with prompt ” Failed to download…”

    • Francois says:

      Path problem.
      display it with ‘echo $PATH’
      or the whole set of environment variables with ‘set’

      Note it should be “. /jffs/setup.relocated”, not “. /setup.relocated”

  4. Mueller says:

    Well, that’s my typo. What I typed was actually “. /jffs/setup.relocated”

    Here’s the snap.

    root@RealPower:/jffs# . /jffs/setup.relocated
    root@RealPower:/jffs# echo $PATH
    /jffs/bin:/jffs/sbin:/jffs/usr/sbin:/jffs/usr/bin:/bin:/sbin

    • Francois says:

      I don’t see anything bad. You should have a working wget in both roots.
      either /usr/bin/wget
      or /jffs/usr/bin/wget
      ‘which wget’ will told you if the shell can find one, and which one

Leave a Reply

Spam protection by WP Captcha-Free