How To: Compact Flash Portable Server
on 11.23.07, 06:08pm in embedded • share on facebook • comments (0)
Back in 2004 I picked up the Asus WL-HDD, a small 2.5″ drive enclosure that also packed a 10/100mb Ethernet connection and could act as an 802.11g access point. While I’ve tinkered around with it a bit (such as making it a 20gb external storage device for the PSP), most of the time it’s just sat in the closet, unused and alone.
I finally pulled the WL-HDD out of the electronics bin earlier this year, when I started to travel more frequently for work. One of the things that I quickly discovered was that the speed of most hotel wireless access points was awful – in fact, on one trip to San Diego, I was actually getting a faster connection using a bluetooth tethered device than over the hotel wifi. By plugging the WL-HDD into the hotel’s wired connection, I could create my own personal hotspot.
One of the things that always bothered me about the WL-HDD was the noise of the drive, and even though it was minimal, the enclosure always felt heavy to me. So I decided to dump the hard drive and go with compact-flash only storage. By using an Addonics AD44MIDECF adapter with a 2GB CF card, it was fairly straightforward to get my flash based portable server that was capable of running apache, PHP, etc.
This worked great for me over the next few months as I continued to travel, but eventually the WL-HDD has made it back into the electronics bin. Today I just use a redhat vm in Fusion and I don’t travel as much now, but it was still a fun little project.
The WL-HDD is a pretty capable little embedded linux box that’s just amusing to tinker with, so I thought I’d post the boring details for bringing up the new firmware and instructions on how to get a PHP web server up and running on it.
Step 1: Flash Oleg’s firmware version 1.9.2.7-8 to the WL-HDD. Once the flash has completed, configure the WL-HDD via it’s web interface, configure it, etc. Turn on Samba support via the web interface.
Step 2: Configure/Enable Samba. Telnet into the WL-HDD and modify (or create) /etc/smb.conf:
[global]
workgroup = WORKGROUP
guest account = nobody
security = share
browseable = yes
guest ok = yes
guest only = yes
log level = 1
max log size = 100
encrypt passwords = no
preserve case = yes
short preserve case = yes
[share]
path = /tmp/harddisk
writable = yes
browseable = yes
force user = admin
Basically, this will create a network share called “share” that’s viewable by the workgroup named “WORKGROUP”.
Step 3: Enable Samba to start on device boot. Via telnet, you’ll want to flash smb.conf to the device, and start samba using the ‘post-boot’ file. To do this, type the following commands:
mkdir /usr/local/sbin
echo /etc/smb.conf >> /usr/local/.files
echo “/usr/sbin/smbd -D” >> /usr/local/sbin/post-boot
echo “/usr/sbin/nmbd -D” >> /usr/local/sbin/post-boot
chmod +x /usr/local/sbin/post-boot
flashfs save
flashfs commit
flashfs enable
reboot
Step 4: Create a swap file for additional applications. Once the WL-HDD has rebooted, telnet into it again. We’re going to create a 64MB file that we’ll use as a mounted swap file that additional applications (such as our webserver) will be installed. More info can be found at http://wl700g.info/showthread.php?t=1917
dd if=/dev/zero of=/tmp/harddisk/opt.ext3 bs=1048576 count=64
mke2fs -j /tmp/harddisk/opt.ext3 (note: answer “yes” when asked)
mount -text3 -oloop,noatime /tmp/harddisk/opt.ext3 /opt
mkdir -p /opt/tmp/ipkg
echo “#!/bin/sh” >> /usr/local/sbin/post-mount
echo “mount -text3 -oloop,noatime /tmp/harddisk/opt.ext3 /opt” >> /usr/local/sbin/post-mount
chmod +x /usr/local/sbin/post-mount
flashfs save
flashfs commit
flashfs enable
reboot
Once the WL-HDD reboots, you’ll see a 64MB file on your harddrive. Internally, the drive mounts this and sees it as a 64MB drive that it can use.
Step 5: Install ipkg. Ipkg is a simple package installer, more details can be found here. Telnet into the WL-HDD:
ipkg.sh update
ipkg.sh install ipkg
echo “src unslung http://wl500g.dyndns.org/unslung” >> /opt/etc/ipkg.conf
ipkg update
ipkg list
This will update ipkg with the latest available packages, and install the binary to our mounted swap drive.
Step 6: Install the thttpd webserver. In your telnet window, type:
ipkg install nano
ipkg install php-thttpd
ipkg install libiconv
Step 7: Configure thttpd. In your telnet window, you’ll want to edit /opt/etc/thttpd.conf:
dir=/tmp/harddisk/www
port=8080
user=nobody
nochroot
nosymlink
novhost
logfile=/opt/var/log/thttpd.log
pidfile=/opt/var/run/thttpd.pid
Save it. This will configure thttpd to run on port 8080, and use /tmp/harddisk/www as the ‘root’ of the website.
Step 8: Enable thttpd to start on reboot. In your telnet window, type:
echo “/opt/etc/init.d/S80thttpd start” >> /usr/local/sbin/post-mount
flashfs save
flashfs commit
flashfs enable
reboot
Whew! If everything worked correctly, when the WL-HDD reboots you should be able to create a simple “index.html” file on your harddisk in the “www” folder, and be able to access it via a browser by going to http://192.168.1.x:8080/index.html (or whatever your device’s IP address is).




