The
$50 Filer
Turning a
wireless router into a fileserver with
DD-WRT
Background
I’ve been
using DD-WRT, a third-party firmware for wireless
routers, on my Linksys WRT54GL for several years to provide DNS,
DDNS, DHCP, and wireless. I recently picked up an
Asus WL-520gU because it has a USB 2.0 port, a
faster processor (240Mhz) and was on sale at Newegg for
only $26.
I was hoping to use the USB to mount an external USB
drive and export it via Samba. Turns out there are tons
of instructions on how exactly to do this, but I wasn’t
able to find all the information in one place. The
following is how I got up and running...
Getting
Started
You’ll need your router, a USB storage
device you want to share (it must be ext2/ext3 formatted to
avoid kludging things), and the DD-WRT firmware. The DD-WRT
version everyone says you need is the Eko NEWD mini build
with USB. Visit here, find the build with the most recent
date (sv10700 when I wrote this), and download
the dd-wrt.v24-_NEWD_mini_usb.bin
file.
Install the Asus tools that came with the router on a
Windows box. Jack directly into the back of the router and
run the Firmware Restoration tool. To prepare the router
for the download, plug it in while holding down the reset
button until the power button blinks on/off once a second.
Click the “Upload” button. It should upload the firmware
and reboot. Wait a minute or so and log into the web
interface (http://192.168.1.1) to set your
username/password (it seems to only like “root” as the
username). On the Services tab, enable “SSHd”, "Core USB
Support", "USB 2.0 Support", "USB Storage Support",
"ext2/ext3 File System Support", and "FAT File System
Support". Click "Save". On the Administration tab, enable
"JFFS2" and click "Save". Wait a 30 seconds or so and then
enable "Clean JFFS2". Click "Apply Settings" and
NOT
"Save".
Log into the router via SSH, run df -h, and you should see the following:
Filesystem Size Used Available
Use% Mounted on
rootfs 2.1M 2.1M 0 100% /
/dev/root 2.1M 2.1M 0 100% /
/dev/mtdblock/4 896.0k 324.0k 572.0k 36%
/jffs
If there is 0 available, try waiting a little longer or
apply the “Clean JFFS2” setting again. Run the following
commands to download the necessary startup script to mount
your drive:
mkdir
/jffs/etc
mkdir /jffs/etc/config
cd /jffs/etc/config
wget http://www.davidlaporte.org/files/optware.startup
chmod +x optware.startup
Reboot the router.
Installing Optware
SSH in and confirm your drive is mounted
with df
-h (you should see
a /dev/scsi/host0/bus0/target0/lun0/part1
entry). Now run these
commands to grab a profile and install Optware:
mkdir
/opt/etc
cd /opt/etc
wget http://www.davidlaporte.org/files/profile
wget
http://www.3iii.dk/linux/optware/optware-install-ddwrt.sh
-O - | tr -d '\r' > /tmp/optware-install.sh
sh /tmp/optware-install.sh
If you get a bunch of errors
about linking, you probably have it formatted as a FAT32
filesystem. Reformat it as ext3 and start over. If you
didn’t see any obvious errors, the packaging system is
installed. Run /opt/bin/ipkg-opt list
to confirm - you should get a
list of available packages.
Installing Samba
To install
Samba, run /opt/bin/ipkg-opt install
samba2. In my reading
it was recommended to add the following between the
killall and startup sections of the Samba startup script
(/opt/etc/init.d/S80samba)
to extend the life of flash devices:
if [ ! -d /tmp/samba ]; then
mkdir /tmp/samba
mkdir /tmp/samba/log
rm -rf /opt/var/log/samba
ln -s /tmp/samba/log /opt/var/log/samba
rm -rf /opt/var/samba
ln -s /tmp/samba /opt/var/samba
fi
To create a share, add the following to the end of
/opt/etc/samba/smb.conf:
[USB]
path = /opt
public = yes
only guest = yes
writable = yes
printable = no
You will also need to change guest account
from pcguest to root, and tweak workgroup, server string, and hosts allow.
This allows anyone to do anything on the share without
authenticating! I use it on my home network and don’t care,
but you may want to “fix” that. Reboot your router, SSH
back in, and run smbclient -L 127.0.0.1 -N
to make sure the shares are
exported correctly.
Get Your Dork
On!
It’s amazing that $50 will get you a pretty solid Linux
box. There’s an onboard 4-pin serial header to play with, network-enabling a USB
printer is as easy as running /opt/bin/ipkg-opt install
p910nd (or so I’m
told, I haven’t tried it), and there are tons of tools
available via /opt/bin/ipkg-opt list
to play with.
Enjoy!
