install debian on a usb stick

Setup good firmware

I used phedny's custom firmware (1.9.2.7-3b) with ipv6 support, you can download it here. Howto install new firmware is described in other howto's on the wl500g forums.

If you don't want ipv6, you can skip setting it up. But hey, why not use ipv6 when I included all kinds of neat ipv6 things like radvd, iproute2, ping6 and traceroute6! Well, read howto setup your wl500g as a ipv6 router

I disabled the stupid-ftp server, because it's .. to simple. Why not use a cool ftpd server when you have a working debian installation? :-) If you have disabled the ftp server on the admin webpages, the usb-storage modules won't be loaded into the kernel. Make sure you have loaded the required modules into the kernel:

Code:
insmod /lib/modules/2.4.20/kernel/drivers/scsi/scsi_mod.o
insmod /lib/modules/2.4.20/kernel/drivers/scsi/sd_mod.o
insmod /lib/modules/2.4.20/kernel/drivers/usb/storage/usb-storage.o
Download the image and store it on the usb memory stick:

Code:
wget -O /dev/scsi/host0/bus0/target0/lun0/disc http://masteen2.iiivx.net/wl500g/debian/debian-sarge-128mb-mipsel.image
this image includes a partition table and stuff, because the ipv6 firmware doesn't have e2fsprogs out of the box. Mount the crazy thing so you can start messing around.

Code:
mount /dev/scsi/host0/bus0/target0/lun0/part1 /tmp/harddisk
Get into your debian installation.

Code:
chroot /tmp/harddisk/debian-distro /bin/bash
mount -t proc none /proc
mount -t devfs devfs /dev
swapon /dev/scsi/host0/bus0/target0/lun0/part2
Generate your own key's and start dropbear
Code:
rm /etc/dropbear/dropbear_rsa_host_key && rm /etc/dropbear/dropbear_dss_host_key
dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
/etc/init.d/dropbear start
Use your fresh debian installation

Now the second part, using your debian installation!

Ssh to your router using the account 'normaluser' and the default password 'userpasswd'. Change your password and type 'su', the default root password is 'rootpasswd'.

Do something kinky like
Code:
apt-get update; apt-get dist-upgrade
And enjoy! Don't forget to regulary clean up the useless stuff I mentioned before.

Additional information

Example of how things can look when everything goes okay
Code:
Feanor:~ iiivx$ ssh normaluser@192.168.1.1
normaluser@192.168.1.1's password: 
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
normaluser@wl500g-router:~$ su
Password: 
wl500g-router:/home/normaluser# uptime
 21:08:10 up 2 days,  8:38,  1 user,  load average: 0.29, 0.36, 0.69
wl500g-router:/home/normaluser# uname -a
Linux wl500g-router 2.4.20 #57 Thu Feb 10 14:29:29 CET 2005 mips GNU/Linux
wl500g-router:/home/normaluser# cat /etc/debian_version 
3.1
wl500g-router:/home/normaluser#

How did I make this? How can this work?

Indeed, "cdebootstrap -amipsel sarge debian-distro http://ftp.de.debian.org/debian" creates a 100 megabyte filetree, and if you unpack the stuff it gets even worse. So I decided to delete all the 'useless' crap.

The first reduction technique is to remove the documentation from the root filesystem. They include the Perl .pod files and everything under the following directories:
Code:
/usr/doc
/usr/info
/usr/man
/usr/share/doc
/usr/share/info
/usr/share/man
Two others that should either be trimmed or eliminated are . . .
Code:
/usr/share/locale
/usr/share/zoneinfo
/usr/share/locale provides locale information, so that users can see the system in their own languages, currency formats, etc. /usr/share/zoneinfo provides timezone definitions, so that users can see local time and perform timezone conversions. Both of these could certainly be trimmed down -- a server which is going to be administered by a single person does not need locale information for languages that person does not speak; and a server which will be used in one place, and does not do complex time-related applications (e.g. calendaring) will never use more than one timezone definitions.

However, removing all of the documentation, the locale, and timezone information only reduces the size of the Debian root filesystem that much, so I also deleted a bunch of not-required libraries and packages. If you miss them, you can install them using apt-get(8).

I ended up using this packages list: debian-sarge-128mb-mipsel-packages.txt

output of my df -h & free -m

Code:
root@wl500g-router:/# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/scsi/host0/bus0/target0/lun0/part1
                      112M   78M   29M  74% /
root@wl500g-router:/# free -m
             total       used       free     shared    buffers     cached
Mem:            13         12          1          0          0          5
-/+ buffers/cache:          6          7
Swap:           10          1          9
root@wl500g-router:/#