WZR-HP-G300NH Modding Guide
I recently upgraded to a Buffalo WZR-HP-G300NH home broadband router after my Linksys WRT54GL router running on DD-WRT died on me. I was looking for a router that could support the custom DD-WRT firmware, USB storage, BitTorrent downloads, Optware and with Wireless-N capability. The Buffalo WZR-HP-G300NH simply met all my requirements!
This article will guide you on how to install a vanilla version of DD-WRT on the router together with the Transmission BitTorrent client running on top of Optware.
Install DD-WRT
Buffalo ships the current models of the WZR-HP-G300NH routers with DD-WRT firmware, but features like SSH are disabled. I was also unable to install additional packages using Optware, therefore I decided to mod the router with a vanilla version of DD-WRT.
For the normal DD-WRT releases, goto DD-WRT Router Database and enter “WZR-HP-G300NH” in the search box. Download the image which is used for the initial flashing.

For the latest DD-WRT releases, go here and navigate to “Downloads -> others -> eko -> BrainSlayer-V24-preSP2″ and navigate further into the latest DD-WRT firmware build directory and download the latest available firmware images.

Flash the router using the router’s web interface once you have downloaded the firmware. I am using the latest DD-WRT firmware that was released on the 24-Dec-2010. Remember to change the password and configure the router as necessary. I will not go into details on the basic configuration for the router as the DD-WRT wiki site has all the necessary details.
Prepare USB Disk
To use the USB disk with the router, at least one of the partitions has to be formatted as ext2 or ext3. I recommend to use the ext3 partition. If you do not have a Linux machine to do the partitioning, do not panic. You can use the MiniTool Partition Wizard Home Edition to modify the partitions of the USB disk within Windows. Create a primary partition and format it as ext3.
Before plugging in the USB disk to the router, enable the USB support in the router. Under DD-WRT web gui, navigate to “Services -> USB” and turn on all the features and set the mount point to be “/mnt”.

To transfer files between the USB disk and to my PC, I use FTP. Enable FTP in the router by navigating to “Services -> NAS”. You can specify username-password combinations for the FTP login if necessary.

Connect the USB disk to the router once you are done.
Directory and mount-point structure
I am using the following directory structure:
- /mnt
mount point for the USB disk
- /mnt/d01/torrent
directory used to hold the torrent configuration as well as the torrent downloads
- /mnt/opt_xx eg. /mnt/opt_01, /mnt/opt_02
different optware installation directories for different possible optware builds
- /opt
this directory will be mounted with a loopback device by pointing to one of the optware directories (eg. /mnt/opt_xx ). this will give the flexibility to test different optware packages just by mounting a different source directory.
Configure Optware and Transmission
The default Optware packages for DD-WRT are built for the mipsel architecture. The Buffalo WZR-HP-G300NH is using Atheros chipset which is based on mips architecture. I got the optware packages for this router from OpenWrt site. Do note that the optware packages will be accessible via a chroot’ed environment.
To proceed further, you will need a SSH client. I am using the free PuTTY SSH client. SSH to the router and run the following commands.
# touch /mnt/optware.enable # mkdir /mnt/opt_01 # cd /mnt/opt_01 # mkdir dev ; mkdir sys ; mkdir proc ; mkdir tmp ; mkdir -p var/lock ; mkdir d01 # mkdir -p /mnt/d01/torrent/dl # mkdir -p /mnt/d01/torrent/.config/transmission # mkdir -p /mnt/d01/torrent/.incomplete # mkdir -p /mnt/d01/torrent/.watch # wget http://downloads.openwrt.org/backfire/10.03.1-rc3/ar71xx/openwrt-ar71xx-rootfs.tar.gz # tar xzvf openwrt-ar71xx-rootfs.tar.gz # echo "export PS1='[\u@\h:(chroot)\w]\$ '" >> /mnt/opt_01/etc/profile # mkdir /opt # mount -o bind /mnt/opt_01 /opt # mount -o bind /mnt/d01 /opt/d01 # for fs in dev sys proc tmp ; do mount -o bind /$fs /opt/$fs ; done # cd / # chroot /opt /bin/sh --login
You should now be in a chroot’ed optware environment. Continue installing the optware packages.
# opkg update # opkg --force-overwrite install coreutils # opkg install transmission-daemon # opkg install transmission-remote # opkg install transmission-cli # opkg install transmission-web # opkg install tune2fs
Now, modify the configuration file, /etc/config/transmission (in the chroot’ed environment), which is used for the Transmission BitTorrent client. The contents of my configuration file can be found below. Take note of the directory related options.
config transmission
option enable 1
option config_dir '/d01/torrent/.config/transmission'
option alt_speed_down 50
option alt_speed_enabled false
option alt_speed_time_begin 540
option alt_speed_time_day 127
option alt_speed_time_enabled false
option alt_speed_time_end 1020
option alt_speed_up 50
option bind_address_ipv4 '0.0.0.0'
option bind_address_ipv6 '::'
option blocklist_enabled false
option dht_enabled true
option download_dir '/d01/torrent/dl'
option encryption 1
option incomplete_dir '/d01/torrent/.incomplete'
option incomplete_dir_enabled false
option lazy_bitfield_enabled true
option lpd_enabled false
option message_level 2
option open_file_limit 32
option peer_limit_global 240
option peer_limit_per_torrent 60
option peer_port 51413
option peer_port_random_high 65535
option peer_port_random_low 49152
option peer_port_random_on_start false
option peer_socket_tos 0
option pex_enabled true
option port_forwarding_enabled true
option preallocation 1
option proxy ""
option proxy_auth_enabled false
option proxy_auth_password ''
option proxy_auth_username ''
option proxy_enabled false
option proxy_port 80
option proxy_type 0
option ratio_limit 2.0000
option ratio_limit_enabled false
option rename_partial_files true
option rpc_authentication_required false
option rpc_bind_address '0.0.0.0'
option rpc_enabled true
option rpc_password ''
option rpc_port 9091
option rpc_username ''
option rpc_whitelist '127.0.0.1,192.168.1.*'
option rpc_whitelist_enabled true
option script_torrent_done_enabled false
option script_torrent_done_filename ''
option speed_limit_down 4096
option speed_limit_down_enabled true
option speed_limit_up 32
option speed_limit_up_enabled true
option start_added_torrents true
option trash_original_torrent_files false
option umask 18
option upload_slots_per_torrent 14
option watch_dir_enabled false
option watch_dir '/d01/torrent/.watch'
Exit out of the chroot’ed enviroment and unmount the USB disk.
# exit # for fs in dev sys proc tmp ; do umount /opt/$fs ; done # umount /opt/d01 # umount /opt # umount /mnt
Enable Autostart of Transmission BitTorrent Client
To automatically start the Transmission client during the router’s startup, we will need to make use of DD-WRT’s startup scripts.
The scripts will auto-mount the USB disk on startup and will also start the torrent client. Once the USB disk is mounted, the scripts will also enable the blue LED at the back of the router. When the disk is unmounted, the blue LED will be turned off.
The scripts will also configure the AOSS switch on the router as a toggle switch. Upon every press of the switch, the scripts will automatically either mount or unmount the USB disk. In this way, you may press the AOSS button to shutdown the torrent client and also to unmount the USB disk before you poweroff the router.
From DD-WRT web interface, navigate to “Administration -> Commands”.
Copy the following code and save it to the ‘Custom Script section:
#!/bin/sh
# usb mount/umount script, this script will be saved in /tmp/custom.sh
# this is where the usb disk will be mounted
USBMP=/mnt
# directory pointintg to the physical optware root
OROOT=$USBMP/opt_01
# directory to mount the optware root; $OROOT will be mounted under this dir
OMP=/opt
# directory where the torrent data resides in the usb disk
TORRENTROOT=$USBMP/d01
# directory to mount the torrent data; must be somewhere under optware root
# $TORRENTROOT will be mounted under this dir
TORRENTMP=$OMP/d01
# GPIO USB led number
GPIO_LED_USB=0
# usb partition 1 device
USBPART1=/dev/sda1
USBFS=ext3
# aoss button script; refer to http://www.dd-wrt.com/wiki/index.php/Script_Execution
AOSS_SCRIPT=/tmp/etc/config/usbdisk.sesbutton
# pidfile
PIDFILE=/var/run/rc_custom.pid
BIN=rc_custom
# the PATH was not set correctly and chroot was not found initially,
# therefore set the PATH variable
PATH=$PATH:/opt/sbin:/opt/bin:/opt/usr/sbin:/opt/usr/bin
# debug flag
debugon=1
# will return 0 if mounted
is_usb_mounted ()
{
grep -q $USBPART1 /proc/mounts
}
usb_mount ()
{
debugprint "attempting to mount usb"
logger -p info -t $BIN "attempting to mount usb"
# if partition does not exist, just terminate
[ -z "$USBPART1" ] && exit 0
debugprint "usb disk found"
sleep 2
mount -t $USBFS $USBPART1 $USBMP
# turn on USB led if mounted
gpio enable $GPIO_LED_USB
is_usb_mounted
[ $? -eq 0 ] && ( debugprint "usb mounted" ; gpio disable $GPIO_LED_USB )
if [ -f $USBMP/optware.enable ]; then
mount -o bind $OROOT $OMP
#mount -o bind $OMP/etc /etc
for fs in dev sys proc tmp ; do mount -o bind /$fs /$OMP/$fs ; done
mount -o bind $TORRENTROOT $TORRENTMP
mkdir /$OMP/var/lock
echo UTC > /tmp/TZ
chroot $OMP /etc/init.d/transmission start
sleep 5
[ -n "`pidof transmission-daemon`" ] && debugprint "transmission-daemon started"
fi
}
usb_umount ()
{
debugprint "attempting to umount usb"
logger -p info -t $BIN "attempting to umount usb"
# transmission takes a while to terminate
n=1
while true; do
chroot $OMP /etc/init.d/transmission stop
sleep 1
[ ! -n "`pidof transmission-daemon`" ] && break
sleep 4
[ $n -gt 5 ] && break
let n+=1
done
# sometimes transmission is not killed properly, if not killed, do not proceed
[ -n "`pidof transmission-daemon`" ] && return
debugprint "transmission-daemon killed"
umount $TORRENTMP
for fs in dev sys proc tmp ; do umount $OMP/$fs ; done
#umount /etc
umount $OMP
umount $USBMP
# turn off USB led if not mounted
is_usb_mounted
[ $? -eq 1 ] && ( debugprint "usb unmounted" ; gpio enable $GPIO_LED_USB )
}
prepare_aoss_script ()
{
#prepare for disk mount/umount when AOSS button is pressed
# return if file is already there
mkdir -p `dirname $AOSS_SCRIPT`
ln -s /tmp/custom.sh $AOSS_SCRIPT
}
debugprint ()
{
[ $debugon -eq 1 ] && printf "usbmount: %s\n" "$1"
}
# before doing anything, check if we are already running
[ -f $PIDFILE ] && [ -d /proc/`cat $PIDFILE` ] && exit
echo $$ > $PIDFILE
mountarg=usbumount
is_usb_mounted
[ $? -eq 1 ] && mountarg="usbmount"
[ $# -eq 1 ] && mountarg=$1
case "$mountarg" in
usbmount)
#is_usb_mounted
#[ $? -eq 1 ] && usb_mount
usb_mount
;;
usbumount)
is_usb_mounted
[ $? -eq 0 ] && usb_umount
;;
prepareaoss)
prepare_aoss_script
;;
*)
exit
;;
esac
rm -rf $PIDFILE
Copy the following code and save it to the ‘Startup’ section:
sleep 20 /tmp/custom.sh usbmount /tmp/custom.sh prepareaoss
Copy the following code and save it to the ‘Shutdown’ section:
/tmp/custom.sh usbumount
Finally, we will need to open the firewall ports for the torrent client to work. Copy the following code and save it to the ‘Firewall’ section:
iptables -I INPUT 1 -p tcp --dport 51413 -j logaccept iptables -I INPUT 1 -p udp --dport 51413 -j logaccept
Save the changes and reboot the router for the changes to take effect.
The web interface for the Transmission BitTorrent client can be accessed on port 9091. If your router’s IP address is 192.168.1.1, try opening the URL http://192.168.1.1:9091/ from your browser.
Final Notes
- To access the chroot’ed Optware environment, run the following chroot command within a SSH session:
# chroot /opt /bin/sh --login
- The block device that I am using in the script to point to the USB disk is /dev/sda1. In older DD-WRT firmwares, it used to be /dev/scsi/host0/bus0/target0/lun0/part1.
- You may want to perform a manual filesystem check on the USB disk once a while to check for a possible filesystem corruption, if any.
- Buffalo has an alternate DD-WRT (Professional) firmware version for this router, but this firmware does not seem to work on Asian models of the same router model.
- The latest Optware packages from OpenWrt can be downloaded from http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/. But the torrent downloads were frequently getting corrupted with the latest snapshots, therefore I opted for an older build of Optware.
| Tags | : bittorrent, buffalo, dd-wrt, optware, transmission, wzr-hp-g300-nh |








Excellent guide, if you follow it step-by-step it works perfectly.
Thanks
Everything is perfect! Thank you for the guide!
Could you add ushare installation as well, pls?
Is it possible to install this to JFFS? I will need just torrent and ushare/minidlna. What changes to this guide it should be then?
…and how to access other partitions in USB disc???
@step, for ushare installation, chroot to Optware environment and do the following:
# opkg update
# opkg install ushare
once installed, configure ushare by following the guide @ http://www.dd-wrt.com/wiki/index.php/Ushare_uPnP_media_server
you can startup ushare automatically by inserting the following code to the script found in the ‘Custom Script’ section:
add in line 75: chroot $OMP /etc/init.d/ushare start
add in line 84: chroot $OMP /etc/init.d/ushare stop
i have not tested the procedure myself, by the way.
@step, the JFFS partition seems to be around 18MB in size, but the optware installation is taking more than 20MB of disk space for me. i am afraid that the installation cannot be performed on a JFFS partition.
to access the 2nd/3rd primary partitions of the USB disk, mount the device /dev/sda2, /dev/sda3 respectively.
eg; to mount the 2nd primary partition under /mmc, run mount as:
# mount -t ext3 /dev/sda2 /mmc
Hi Ibrahim,
Please can you help me, please?
From almost 2-3 week’s i tried to configure my router WRT160NL Linksys.
I wish to atach an external hdd 1TB Seagate Expansion to the router, and instal/configure ftp, optware, transmission. Almost i gave up to set the hdd and the stuff. I don’t know why the partition it is not mounted on the startup. I tried several commands, but none is not working. If i put the command manualy from Putty, the partitions are mounted, but the same commands put in the Commands of the router is not working. The router recognize all partition on WebGui from DDWRT. Now i am running the latest firmware. If you want read some more, i posted on forum ddwrt . If you want some information please tell me. Can you help me somehow? Any advice i’ll apreciate! Thank you very much!
@Mihai, have you tried placing a sleep command before mounting ? maybe you could try inserting this command before mounting the hdd:
sleep 20
if you are still facing problems, try to redirect the stderr output of the mount command in the Commands section:
e.g, mount -t ext3 /dev/… /opt 2> /tmp/merr.log
restart the router and SSH in and check the contents of the file /tmp/merr.log. it may give you some clues. good luck!!
Have you noticed any of the wireless issues reported by many using pretty much any other firmware (i.e. stock of any version, “official professional” DD-WRT, DD-WRT “recommended” on the router database main page, or OpenWRT)?
Thanks, nice guide!
@Ibrahim Brilliant guide! Hoping you can help me with a bump I seem to have hit. Breezed through all steps, but getting “* opkg_conf_init: Couldn’t stat /etc/opkg.conf: No such file or directory.” when I run “opkg update”
Any suggestions?
@pevi, it could be that the chroot command did not get executed correctly. this usually happens when the uClibc libraries are different in DD-WRT and the OpenWRT packages. you can try your mileage with older/newer packages from OpenWRT. you can also try running chroot as follows:
# (LD_LIBRARY_PATH=/opt/lib:/opt/usr/lib:/lib:/usr/lib ; chroot /opt /bin/sh –login )
@james, so far, my wireless connection has been very stable on DD-WRT!!
Thanks @Ibrahim, the chroot command you suggested got things moving again for me. Though, even now unable to access the transmission web UI. Could this mean that the variation in my setup also needs me to make some other changes along the steps/scripts in your guide? Appreciate your advise.
Thanks again!
@pevi, yes, you will also need to change all the chroot commands in the scripts as well.
Hi, how to config USB Eject Button to mount and unmount USB disk, instead of using AOSS button?
@William, based on my understanding, DD-WRT only supports AOSS button for script execution. You can get more info at http://www.dd-wrt.com/wiki/index.php/Script_Execution
If you know of any other way to detect a USB eject button press event, do let me know so that I could modify the script.
just wanted to say THANKS
this guide was exactly what i was looking for
it worked perfectly with no issue on my TP-link 1043
THANKS A LOT
M
Worked great on my TP-Link TL-WR1043ND when I followed the instructions step by step. I jumped ahead and borked it the first time, thinking I knew better. Had to restore to factory firmware and then reflash to DD-WRT. One question though, your screen cap talking about FTP enabling shows an option for File Sharing/SAMBA. My firmware “DD-WRT v24-sp2 (08/07/10)” doesn’t include that. Is that your own mod or is there a newer firmware available that has that feature enabled? Thanks for the guide!
@G3MINI, good to hear that the article helped you configure your router. the file sharing option is available in the test-builds. you can get test-build r17201 for your router here. but do take note that the test-builds are not always stable.