Mounting the sd card to the root directory

By mounting the sd card to the root directory the WRT54GL still boots from its internal memory (4MB) and runs an init script, that mounts the sd card to /, if a sd card with the appropriate data is inserted. Thus you can install packets normally and dont have to worry about scripts in the installed package looking for data in the wrong place. This problem came up when I tried to install shorewall (a firewall) to my sd card at /mmc . There were some scripts looking for data in wrong places, for example in /var/lib/shorewall instead of /mmc/var/lib/shorewall .
Whatever you install when a sd card is inserted wont be there, if you boot without the sd card. You can use this for example when setting up 2 different sd cards, one for normal use of the WRT54GL as a router, the other one as a WLAN sniffer. I think there are a lot of good ideas how to use this feature.

preparing the sd card

In order to put the data required to mount the sd card to / on it, use the following commands on the shell:
mkdir /tmp/root
mount -o bind /rom /tmp/root
mount -o bind / /tmp/root
cp /tmp/root/* /mmc -a

automatic initialisation of the sd card

rm /sbin/init

Now we have to replace the /sbin/init which has just been deleted with our /sbin/init. There are 2 possibilities: use ftp to move it simply from your computer to /sbin/ on the WRT54GL. Or use the text editor vi on the shell that you get by logging in via ssh. Create a new file and cut&paste the content of the file into it. Using ftp is easier. For using vi type in the shell:
vi /sbin/init
Press the button i. Open the file with your favourite editor on your local machine,
mark everything,
press ctrl-c,
open the window containing the ssh session,
press ctrl-v
press escape,
type:
:wq
press enter.
You're done.
Make the file executable: chmod a+x /sbin/init
reboot your router:
reboot
As soon as the routers finished (give him about 1 minute), log in with ssh again.
Try
df -h. You should see that /dev/mmc/disc0/part1 is mounted to / .




Your WRT54GL is more or less a 200MHz computer running a linux with a ssh server and a ftp server, acting as a router, firewall and wlan access point. And now it has about 400 times more memory as before, if you put a 2GB sd card into it.

Lets go on setting up DynDns on OpenWRT White Russian.