SD Card on OpenWrt

I recently switched to OpenWrt, as I had some problems with DD-Wrt and more important I just wanted to try it out. The change was pretty seamless, as most nvram variables are shared and therefore I didn’t even have to change much for the router to work correctly. If you don’t plan to go back to DD-WRT this script cleans up your nvram variables.(deleting those that aren’t used by OpenWrt)

Now you need to download the MMC Card module:

cd /lib/modules/2.4.30


See comments for an alternative link, if the one above doesn’t work.

Your card should be formated with ext2. The drivers for the ext2 filesystem are needed, too. They can be installed via a ipkg package:

ipkg update
ipkg install kmod-ext2

insmod ext2

Now you can test if the card works:

echo “0x9c” > /proc/diag/gpiomask
insmod mmc

mount /dev/mmc/disc0/part1 /mmc

Note: The gpiomask fits to the modification I described in the post below, adapt it corrosponding to your modification.

When I used DD-WRT my card was mounted under /mmc. Installing software in that mount-point caused same problems, hence I decided to mount the SD-Card to the root directory in OpenWRT. This enhances your available memory very seamlessly. Furthermore it would be possibly to have differend SD-cards containing different configurations of OpenWRT. If no card is attached the system will start in the normal behavior. First the needed files will be copied to the card:

mkdir /tmp/root
mount -o bind /rom /tmp/root
mount -o bind / /tmp/root
cp /tmp/root/* /mmc -a

/sbin/init is a link to the busy box init. This will be replaced with our own init script which will do the work for mounting the card to / and after that execute the init of busy box.

rm /sbin/init

This is the new init script(copy paste it to /sbin/init), after that make i executable(chmod +x /sbin/init)

echo “0x9c” > /proc/diag/gpiomask
insmod mmc
insmod ext2

sleep 15s
mount “$boot_dev” /mmc
[ -x /mmc/sbin/init ] && {
mount -o move /proc /mmc/proc && \
pivot_root /mmc /mmc/mmc && {
mount -o move /mmc/dev /dev
mount -o move /mmc/tmp /tmp
mount -o move /mmc/jffs2 /jffs2 2>&-
mount -o move /mmc/sys /sys 2>&-
exec /bin/busybox init

Now reboot. run


to test  if it works correctly. If the router doens’t boot or something doesn’t work as intended you can remove the card an everything should be just like before.


Tags: , , , ,

2 Responses to “SD Card on OpenWrt”

  1. justyjusty123 Says:

    wget …/mmc.o

    The link above does not work at the moment. Can anyone post the mmc.0 driver needed?


  2. tdomhan Says:

    uploaded my mmc.o:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: