OpenWRT on NSLU2 (part 1)

by cmur2 on 2012-11-30 in Linux

For those who still own one of the great Linksys NSLU2 devices there is the great possibility (besides using e.g. Debian 5 (Lenny) which is officially discontinued at the time of this writing) to easily flash OpenWRT in few minutes. There is no need for an external USB storage since OpenWRT is able to run complete from the 8 MiB integrated flash and there are even 4.36 MiB (92%) available for software installation on my NSLU2.

I installed the latest stable release of OpenWRT “10.03.1 Backfire” using the image provided here. The installation instructions from here are still valid regarding the usage of the upslug2 utility:

# your NSLU2 should be in upgrade mode
upslug2 -i openwrt-nslu2-squashfs.bin

At least since Backfire the NSLU2 will be reachable (after reboot triggered by upslug2) under and not using the last network config stored in the NVRAM! But it may take several minutes (for me it took around one or two) since OpenWRT initializes the JFFS2 payload partition on first boot. Some troubleshooting tips are listed here (German).

Now you should login using telnet or via web-interface called LuCI and change/specify a root password to enable the SSH server included (Dropbear, can be replaced by OpenSSH if you want). The network settings are to be found under Network > Interfaces > LAN in LuCI. From here on your device is fully customizable :)

LEDs and beeper

By default only the ethernet LED will show activity (hard-coded) but you can use the remaining three (actually four since ready/status are two different colored LEDs) and configure them through LuCI under System > LED Configuration. I choose nslu2:green:ready to use the trigger defaulton to signal that my slug is running.

For the beeper people say it’s enough to opkg install kmod-input-core kmod-input-evdev to get the /dev/input/event0 device which you than can use to beep though I did not try it out.

Minimal USB storage support

It took me 312 KiB to get my noname USB stick with only ext3 and swap partitions working and mounting. No fdisk (partitioning may be done on other computer) and no e2fsprogs for filesystem check and tuning yet.

opkg install kmod-usb2 kmod-usb-storage

This should make your kernel recognizing the internal USB hub and the connected stick including its partition table. To gain ext3 mounting support:

opkg install kmod-fs-ext3

fstab, auto-mount on boot and LuCI


opkg install block-mount
/etc/init.d/fstab enable
/etc/init.d/fstab start # will trigger 'WARNING: /lib/functions/fsck not found' since e2fsprogs is missing

you will have fstab and auto-mounting on boot capabilities for ext3 and swap and a new LuCI entry under System > Mount Points. Now you can either do vi /etc/config/fstab or use the web-interface for configuration. (I did not need special Native Language Support packages, not even the UTF-8 package.)

So at least I thought I had auto-mounting on boot capabilities. But there is a bug in the fstab init-script that prevents mounting because of a timing problem so you should add an sleep 15 in the start() function declaration (in my case in row 42 :)).

Even though the disk is going to be mounted on boot I followed this advice.

opkg on USB storage

When you have a USB storage attached you generally want to use it. I wanted to store some of the bigger software packages on it to preserve flash memory for some important/small things.

As this section in the OpenWRT wiki states quite strongly this is going to cause trouble because most of the packages are not able (or at least, not aware) to run from another location except /. And even software that is needs some tweaks for PATH and LD_LIBRARY_PATH to allow proper execution.

First you need to add a new installation destination to /etc/opkg.conf:

src/gz packages
dest root /
dest ram /tmp
dest opt /mnt/usb/opt
lists_dir ext /var/opkg-lists
option overlay_root /overlay

(I mount my ext3 partition in /mnt/usb and created an opt directory on it: mkdir /mnt/usb/opt; ln -s /mnt/usb/opt /opt)

Now when you want to install a package to your USB stick run:

opkg install -d opt foobar-package

You should edit /etc/profile to extend PATH and LD_LIBRARY_PATH:

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin:/opt/usr/bin:/opt/usr/sbin
export LD_LIBRARY_PATH=/lib:/usr/lib:/opt/lib:/opt/usr/lib

For packages with init scripts you also need to copy these lines to the beginning of the init script. For some packages relying on files in /usr/share/ or providing some config in /etc/ you also need to symlink these into your root file system.

Update: If you want to find out to which destination you installed a package, run opkg files foobar-package that outputs something like:

Package foobar-package (<version>) is installed on <destination> and has the following files:


Next part will probably cover the setup of OpenVPN, IPv6 and replacing dropbear with OpenSSH (since there exist many reasons…).

Other sources

The post »OpenWRT on NSLU2 (part 1)«
is licensed under Creative Commons BY-NC-SA 3.0.