[[My Debian Linux on the NSLU2 installation and configuration guide]]
 

A step-by-step practical guide to installing & configuring Debian Linux on the NSLU2, together with some very common applications and instructions on how to do some hardware modifications on the Linksys NSLU2, by Sebastiaan Giebels [sgie bels_nslu2ATpc probleemloos.nl].

What is a NSLU2?

The NSLU 2 is a small form factor networking device, with a 100Mbit ethernet connection and 2 USB2.0 ports for attaching USB storage devices (disk drives and flash drives) to be used on the network (Windows file sharing, FTP, etc). It is distributed by Linksys (a Cisco division) and it runs on Linux. Some people like to call it a NAS (Network Attached Storage device), although no drives/disks are supplied with it. Linksys NSLU2 product page

What is Debian

A distribution of the Linux operating system http://www.debian.org available for many architectures (=types of processors), including the 'ARM' (the processor in the NSLU2).

Why would one want to run Linux on the NSLU2 or perform hardware modifications to it?

The Linux distribution preinstalled by Linksys on the device is rather limited, for example it's only possible to use USB storage devices. By installing linux yourself (and the proper drivers) you can use other USB devices (such as camera's, printers, wireless network adapters), run many more software titles (all freely available), just as you could with a real linux machine.

It's like turning a shopping cart into a shiny looking car, and the good thing: all of this can be done for free!

URL: Linux on the NSLU2 page

Besides the software aspect of mods, it's also possible to tinker with the hardware: enable the 'hidden' USB ports, have the device power up automatically when power is applied, or change the CPU speed from 133Mhz to 266Mhz (newer models however are already running at 266Mhz factory-default). All these hardware modifications require soldering, so you might start with 'just running Linux on it' if you're not that much of a hero ;)

Why this guide?

There is a great website on this subject: http://www.nslu2-linux.org/, and I've got a lot of information from there. It has a public wiki, so I could also have written this text there. However, there is a lot of information there that I don't need, so I want to have a page containing just the things I've done with this device. You could also see it as a journal on my experiences with the NSLU.

Who am I?

I work as an IT consultant for PC Probleemloos in Eindhoven, The Netherlands and I'm a Linux & BSD enthousiast. I have an computer-science/electrotechnical/electromechanical background. Besides being a supporter of open source software, I like good technology and properly designed products like the NSLU2. However, with a broken power adapter for one of my NSLU2's (noticable by the high pitch sound coming from the adapter and the NSLU2 not booting) and the Linksys policy requiring me to send both power adapter _AND_ my (heavily modded, but not broken) NSLU2 back for repair (read: complete product replacement), I've removed the words 'sold by a customer-friendly company' from the previous line.

Getting started

I'll show step-by-step how to get common applications running on the Linksys NSLU2 (Network Storage Link for USB 2.0 Disk Drives), and I'll show you how I've configured mine.

A good starting point for getting Linux on the NSLU2 is http://www.nslu2-linux.org/wiki/Debian/HomePage
I've used the 'manual' Debian installation method, described at the website http://www.cyrius.com/debian/nslu2/unpack.html
It's dedicated to the NSLU2 (so a lot of settings are set up properly for NSLU2 use) and worked perfectly on my device. Follow the instructions (first, create the neccessary partitions, minimun 500MB for /dev/sda1, on an USB stick, unpack the Debian distribution to this partitions, and flash the firmware your NSLU2 using the upslug2 tool.

After installation, there are a few things you should not forget (there is mention of it in the cyriuys.com article, but the exact commands are not given):

. Change the root password: Login as root, then enter:

passwd

Enter a new password (twice)

Add normal user accounts

adduser <my_username>

Fill in the details (such as the password)

Regenerate the system SSH-key:

cd /etc/ssh/
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''

('-N' specifies the password, in our case it's empty. 'rsa1' probably not required) There is a tool to check your key against a recent OpenSSH attach, where the Debian (and Ubuntu) ssh keygenerator wasn't creating secure keys. See OpenSSH.org for more details. If you have previously connected to this machine, the next time you'll connect, you will get a 'key has changed' warning. Remove the corresponding entry in ~/.ssh/known_hosts and retry.

Change the timezone you live in:

tzconfig

Add additional user accounts

As a security measure, you might want to disable root ssh logins in /etc/ssh/sshd (?)

Flash drive as boot drive

I've connected a 1GB flash disk to the NSLU2, and I'm going to put my Debian on this drive. I suggest using 1GB or larger. 512MB might work too, but will probably require you to decide which parts of the debian system you won't use that could be deleted.

Preventing flash writes / Reduce wear on flash memory

URL: http://www.nslu2-linux.org/wiki/Unslung/Ext3flash URL: http://www.nslu2-linux.org/wiki/Debian/FAQ

How can I avoid swapping / beating up my flashdrive? You want to minimize the writes to your flash drives, as flash/usb drive media quality decreases after a number of writes. I won't disable swapping to flash however. Using flash temporarily is better than crashing totally I think.

1: Mount your partitions with the 'noatime' parameter.

My /etc/fstab file, note the 'noatime' option, to prevent updating the file-access-timestamp each time a file is read (atime='access-timestamp'), thus preventing a lot of write actions to the flash disk. If you don't use noatime, every file read will also perform a write to update the access time information. See Ext3flash for up to date information on achieving this.

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/sda1       /               ext3    defaults,errors=remount-ro,noatime 0       1
/dev/sda6       /home           ext3    defaults,noatime        0       2
/dev/sda5       none            swap    sw              0       0
/dev/sda1       /media/usb0     auto    rw,user,noauto,noatime  0       0
/dev/sda5       /media/usb1     auto    rw,user,noauto,noatime  0       0
/dev/sda6       /media/usb2     auto    rw,user,noauto,noatime  0       0

http://www.nslu2-linux.org/wiki/HowTo/FixSlowBootup

2: Let the system know not to hammer the flash memory and wear it out

Create a file .ext3flash in the root folder:

touch /.ext3flash

3: Minimizing the swap usage:

If you have a swap partition on flash, it might be a good idea to change the kernel's swapping behaviour to minimize swapping:

View the current kernel/proc/system setting on swapping behaviour:

cat /proc/sys/vm/swappiness
60

'Depreciate' swapping, by setting it to '0':

echo "0" > /proc/sys/vm/swappiness

4: Disable 'MARK' messages in syslogd options:

nano /etc/default/syslogd

Add:

SYSLOGD="-m 0"

5: Prevent logging of unimportant stuff

Look at your log files, and see if you are recording more than you need. You can also instruct syslog to buffer its output, avoiding writes after every line, by putting a - before the filename in syslog.conf. .bash_history logging

Optional:

Disable disk integrity checks. This is done because in some situation, it would take forever at boot time (or even don't boot as some have reported). /sbin/tune2fs -c 0 -i 0 /dev/sda1 Note:

  • ”-c 0” disables disk integrity checks that normally occuring every 33 mounts.
  • ”-i 0” disables disk integrity checks that normally occuring every 180 days

Flash Read and write speeds

Some flash drives are faster than others. You can measure the speed of your drive as follows:

My model (no-name 'USB DISK 20X'):

drivers/usb/input/hid-core.c: v2.6:USB HID core driver
  Vendor:           Model: USB DISK 20X      Rev: PMAP
  Type:   Direct-Access                      ANSI SCSI revision: 00
(no-name brand)

Read speed

nslu2:/# dd if=/dev/sda1 of=/dev/null bs=10000 count=10000
10000+0 records in
10000+0 records out
100000000 bytes (100 MB) copied, 11.1673 seconds, 9.0 MB/s

Write speed

dd if=/dev/zero of=/home/delete_me.tmp bs=1M count=30
30+0 records in
30+0 records out
31457280 bytes (31 MB) copied, 10.3701 seconds, 3.0 MB/s
rm /home/delete_me.tmp

Memmory issues

The NSLU2 has just 32MB of RAM. Don't use more RAM than you have, or it will swap portions of memmory to your flash drive (which is not good) Check 'top' to make sure the swapping stays low (look for '0.0%wa' or '0.0%swap', and 'Swap … ..k used'), or else your NSLU2 is slowly destroying your flash drive…

A Few lines of 'top' output of my NSLU2:

Tasks:  37 total,   1 running,  36 sleeping,   0 stopped,   0 zombie
Cpu(s):  1.0%us,  0.3%sy,  0.0%ni, 98.7%id,  0.0%wa,  0.0%hi,  0.0%si,  
0.0%st
Mem:     29988k total,    28436k used,     1552k free,     6232k buffers
Swap:    56188k total,       40k used,    56148k free,     8752k cached

To save more memmory: Disable appletalk?
exim or postfix?
dropbear or openssh?
proftpd or …?
apache, httpd, boa?

Use apt-get instead of the user-interface 'aptitude', and don't update the cpan 'available perl modules' database. Install cpan modules by hand.

Use 'ps auxww' or 'free' to view the memmory used by the applications.

To see which kernel modules are loaded into memory:

lsmod

Example output:

Module                  Size  Used by
ledtrig_heartbeat       3040  0
dm_snapshot            17180  0
dm_mirror              20948  0
dm_mod                 59120  2 dm_snapshot,dm_mirror
rtc_dev                 7432  0
ixp4xx_mac             19572  0
evdev                  10400  0
ixp4xx_qmgr             8652  5 ixp4xx_mac
ixp4xx_npe             14368  2 ixp4xx_mac
ixp4xx_beeper           3616  0
firmware_class         10656  1 ixp4xx_npe
ext3                  137704  2
jbd                    59368  1 ext3
mbcache                 9188  1 ext3
sd_mod                 19248  4
usbhid                 53252  0
usb_storage            77707  3
scsi_mod              102800  2 sd_mod,usb_storage
ehci_hcd               31240  0
ohci_hcd               17156  0
usbcore               126920  5 usbhid,usb_storage,ehci_hcd,ohci_hcd

Beep ip address trough internal speaker

Make sure 'beep' is installed

apt-get install beep

Basic usage: beep -l <LENGTH> -f <FREQUENCY>
-l length, in ms (I use 10 - 1000)
-f (frequency, between 1 and 130 works here)
-d <DELAY>: wait a number of ms after beeping

Here's a shell script to beep an IP address trough the internal speaker on the NSLU2 I use it to find out which ip address my NSLU2 got assigned by DHCP. It simply plays/beeps the numbers of the ip addres trough the speaker. We'll configure it to auto start on boot, so you'll never have to worry which ip addres the device is on.

#!/bin/sh
# Beep ip address trough internal pc speaker
# Tested on Debian Linux @NSLU2
# Author: Sebastiaan Giebels, 2007

# Retreive dot-separated ipv4 address from the ifconfig information, using grep and cut:
IPADDRESS=`/sbin/ifconfig | grep -A1 "eth0" | grep "inet" | cut -d: -f 2 |cut -d" " -f1`

# Enable next line for debugging:
#echo $IPADDRESS

#Uncomment this for an example with zeroes in the ip address:
#IPADDRESS="10.0.0.1"

# For all characters in dotted ipv4 address:
for ((a=0; a < ${#IPADDRESS} ; a++))
do
  # Get the next character to process:
  NUMBER=${IPADDRESS:$a:1}

  if [ "." == "$NUMBER" ]
  then
    # Different note to signal a '.' in the address:
    `/usr/bin/beep -l 20 -f 25 -d 20`
  else if [[ "$NUMBER" -ge "0" && "$NUMBER" -le "9" ]]
    then
      # Beep 'NUMBER' times, except for 0 (=beep 10 times):
      if [ "$NUMBER" == "0" ]
      then
        NUMBER=10
      fi
      `/usr/bin/beep -l 45 -f 15 -d 150 -r $NUMBER`

    fi
  fi
  sleep 1
done

Save the script as '/bin/beep_ip.sh', then:

chmod ugo+x /bin/beep_ip.sh

Test it:

/bin/beep_ip.sh

Configure it to auto-start upon next boot:

nano /etc/rc.local

Insert the following text just above the last 'exit 0' line:

/bin/beep_ip.sh

Although not required, you can now reboot to test it.

I've written another (simpler) script, that just outputs a few tones. I use it in /etc/rc.local to signal to me that the NSLU2 has finished booting.

#!/bin/sh
#Output a few notes trough the internal speaker:
#You can play multiple notes with one command, use the -n between the -f/-l/-D parameters
# Tested on Debian Linux @NSLU2
# Author: Sebastiaan Giebels, 2007

/usr/bin/beep -e /dev/input/event0 -f 329.628 -l 100 -D 20
/usr/bin/beep -e /dev/input/event0 -f 391.995 -l 100 -D 20
/usr/bin/beep -e /dev/input/event0 -f 523.251 -l 100 -D 20
/usr/bin/beep -e /dev/input/event0 -f 261.626 -l 300

I saved this text as /bin/beep_1234.sh, and to make it executable, I entered:

chmod ugo+x /bin/beep_1234.sh

Change function of power button

URL: http://www.nslu2-linux.org/wiki/Debian/FAQ Quote: 'How do I change the function of the power button on the NSLU2 to shut the system down as opposed to rebooting it?'

nano /etc/inittab

Change the line:

ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

to:

ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -h now 

('-r' means reboot, '-h' means 'halt')

Disable IPV6

I don't use ipv6 on my NSLU2 at the moment, so I'll turn it off. First, check if it's really enabled:

ifconfig

Look for a line beginning with 'inet6' (actual numbers will vary):

          inet6 addr: fe80::213:10ff:fed3:a853/64 Scope:Link
lsmod | grep ipv6
ipv6                  269672  12

Presence of these lines confirm that ipv6 is enabled.

To disable IPv6:

nano /etc/modprobe.d/aliases

Change:

alias net-pf-10 ipv6

to:

#alias net-pf-10 ipv6
alias net-pf-10 off

You can check the result using ifconfig after you have rebooted.

Connecting USB peripherals to the NSLU2

Silvershield/Gembird SiS-PM

Some instructions for if you have Debian Linux installed on your NSLU2, and you want to connect the Gembird SISPM USB controlled power socket/outlet with the NSLU2

Download the latest version of sispmctl from the official website http://sispmctl.sourceforge.net and extract ut

cd /usr/src
wget http://switch.dl.sourceforge.net/sourceforge/sispmctl/sispmctl-2.4b.tar.gz
tar -zxvf sispmctl-2.4b.tar.gz

It comes distributed as source, so we will need to compile it:

cd sispmctl-2.4b
./configure
configure: error: no acceptable C compiler found in $PATH

Ok, so we'll install a C compiler, like 'gcc' together with the libc sources, and the 'make' tool:

apt-get install gcc libc6-dev make

We also need the libusb sources:

apt-get install libusb-dev

Retry configure:

./configure

If all went well, you should see:

...
Good - your configure finished. Start make now
make 
make install

After installation, the folder /usr/local/share/httpd/sispmctl/ will contain some web interface stuff, and the main application is here: /usr/local/bin/sispmctl

Let's try to start it:

/usr/local/bin/sispmctl
No GEMBIRD SiS-PM found. Check USB connections, please!

Have I already told you to connect it? If not, please do so now. Avoid USB hubs at first, till things work. You can always 'expand' your situation by adding an USB hub, but please try plugging it in directly to your NSLU2 first

/usr/local/bin/sispmctl -s
Gembird #0 is USB device 003.This device is a 4-socket SiS-PM.

Indicating the device has been detected. You can use the parameters '-o #' or '-f #' to power On or power oFf a socket, where # is the socket number (1,2,3 or 4). E.g.: power off device at socket 2:

/usr/local/bin/sispmctl -f 2

I have only one SiS-PM device, haven't tested more of them connected togeter to one NSLU2.

Silver Shield

Hardware modifications

Opening the case

I have to make a video for this one. Please remind me to do so.

De-underclocking

The models produced before ../2006? have their IXP4 processors underclocked. They're running on 133Mhz, instead of the 266Mhz it can run.

Checking the CPU speed to determine if your NSLU2 is underclocked

To check if your NSLU2 is running at the fastest speed (266Mhz), enter the linux command:

cat /proc/cpuinfo

The first lines:

Processor       : XScale-IXP42x Family rev 1 (v5l)
BogoMIPS        : 266.24
Features        : swp half fastmult edsp
...

The number at the 'BogoMIPS' line is not very accurate, but it should show a value of about 266. If it's 133, it's time to OverClockTheSlug

Automatically boot-up on power

To have the NSLU2 automatically start/boot whenever power is applied to it, requires a tiny bit of soldering, and just one component: …

Also check the software mod: Change function of power button, to have the NSLU2 powerdown instead of reboot when pressing the power button.

cpuinfo output

cat /proc/cpuinfo
Processor       : XScale-IXP42x Family rev 1 (v5l)
BogoMIPS        : 266.24
Features        : swp half fastmult edsp
CPU implementer : 0x69
CPU architecture: 5TE
CPU variant     : 0x0
CPU part        : 0x41f
CPU revision    : 1
Cache type      : undefined 5
Cache clean     : undefined 5
Cache lockdown  : undefined 5
Cache format    : Harvard
I size          : 32768
I assoc         : 32
I line length   : 32
I sets          : 32
D size          : 32768
D assoc         : 32
D line length   : 32
D sets          : 32

Hardware        : Linksys NSLU2
Revision        : 0000
Serial          : 0000000000000000

References

Junk below this line

Current issues

http://www.nslu2-linux.org/wiki/HowTo/KeepRemoteConsoleSessionRunning http://www.nslu2-linux.org/wiki/HowTo/AutoRebootOnPanic echo “kernel.panic=5” » /etc/sysctl.conf what's this?: /USR/SBIN/CRON[2806]: (root) CMD ( [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$ …

nano take_preview_photo.cgi

#!/bin/sh

cd /mnt/
echo Content-Type: image/jpeg
/usr/bin/gphoto2 --camera STV0680 --stdout --capture-preview > /dev/null
echo
cat /mnt/capture.pnm | /usr/bin/pnmtojpeg
rm /mnt/capture.pnm

Wireless network

Currently not working.

List all connected USB devices:

lsusb
Bus 003 Device 014: ID 083a:4505 Accton Technology Corp.
Bus 003 Device 012: ID 07d1:3c03 D-Link System
Bus 003 Device 002: ID 0d7d:1600 Phison Electronics Corp.
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000

Install the wireless tools & WPA encryption support packages:

apt-get install wireless-tools
apt-get install wpasupplicant

ndiswrapper won't work on the NSLU2, as it's intel x86 based. Note that some drivers are wrong-endian, these won't work either.

Load the driver (in my case, it's the zd1211rw for an Accton 083a:4505 device)

modprobe zd1211rw
dmesg
ieee80211_crypt: registered algorithm 'NULL'
ieee80211: 802.11 data/management/control stack, git-1.1.13
ieee80211: Copyright (C) 2004-2005 Intel Corporation <jketreno@linux.intel.com>
usbcore: registered new driver zd1211rw

http://www.nslu2-linux.org/wiki/Peripherals/WirelessNetworkAdapter

nslu2:/sys/module/zd1211rw# ifconfig eth1 up eth1: ERROR while getting interface flags: No such device

nslu2:/sys/module/zd1211rw# modprobe zd1211 FATAL: Module zd1211 not found.

http://rt2x00.serialmonkey.com/wiki/index.php?title=Downloads

apt-get install linux-wlan-ng


apt-get update apt-get install linux-headers-2.6.18-5-ixp4xx http://www.nslu2-linux.org/wiki/DebianSlug/InstallRT2570 http://wiki.zenwalk.org/index.php?title=Zd1211-firmware

apt-cache search

http://rt2x00.serialmonkey.com/phpBB2/viewtopic.php?t=838& Bus 003 Device 003: ID 07d1:3c03 D-Link System

Bus 003 Device 004: ID 083a:4505 Accton Technology Corp. SMC EZconnect g SMCWUSB-G Zydas ZD1211?

Linux nslu2 2.6.18-5-ixp4xx #1 Thu Sep 27 12:27:55 UTC 2007 armv5tel GNU/Linux

zd1211-firmware ZyDAS ZD1211 Firmware zeroconf

wpa-supplicant wpa_supplicant is a WPA Supplicant for Linux, BSD and Win… wpa-supplicant-cli A Client for Wi-Fi Protected Access (WPA). wpa-supplicant-passphrase

apt-get install zd1211-source

0cf3:0002 Atheros Communications, Inc. SENAO / engenius

killall

I regularly use 'kill', but there's 'killall', which is easier to use. Installation:

apt-get install psmisc

Usage:

kill <application_name>

(e.g.: kill httpd to kill a running apache webserver) There's also 'slay', but it's not the same pstree also contains fuser and pstree

netstat -4an

sudo apt-get install dpkg-cross fakeroot werkt niet: http://ftp.armeb.net/debian-sarge/pool/main/ sudo apt-get install apt-src sudo apt-src install binutils

apt-get install etherwake

Named / dns server

I'll install a DNS server, and I'll use it to block requests to banner-sites. Ad-free surfing

URL: www.isc.org Installation:

apt-get install bind

Configuration:

cd /etc/bind/
nano named.conf.options

Just before the last '};', insert the following lines, and adjust them:

allow-recursion  {           // Disable any recursive queries from outside:
  <my.network.ip.range>/<mask>;   // Queries from DMZ are OK
  192.168.0.0/16;     // Queries from HSZ are OK
  10.0.0.0/6;     // Queries from HSZ are OK
  localhost;            // Local Queries are OK
};
forwarders {
  <my_isps.first.dns.server>;
  <my_isps.second.dns.server>;
};

Add the following line to /etc/bind/named.conf:

include "/etc/bind/named.conf.block";
nano named.conf.block

For each domain you want to block ads for (in my example it's the domain 'googlesyncidation.com'), add and edit the following line:

zone "googlesyndication.com" { type master; file "/etc/bind/dummy-block"; };

Remind me to put up a list with ad-spewing hostnames, or search same subject on my 'FreeBSD installation and configuration page', section 'named / bind'

nano dummy-block
$TTL 24h
@       IN SOA example.org. hostmaster.example.org. (
        2006052800      ; Serial yyyy/mm/dd/id
        86400           ; Refresh (24 hours)
        300             ; Retry (5 minutes)
        604800          ; Expire (7 days)
        3600 )          ; Negative Cache TTL (1 hour)

@       IN      NS   ns2.example.org.
@       IN      A    <nslu2.ip.address.here>
*       IN      A    <nslu2.ip.address.here>

I've configured ns2.example.org to resolv to <nslu2.ip.address.here>.

If you copy the dummy-block file to /var/cache/bind, like this:

cp dummy-block /var/cache/bind

You don't have to specify the full path to that file in your named.conf, so

{ type master; file "/etc/bind/dummy-block"; }

becomes

  { type master; file "dummy-block"; }

To have the nslu2 itself use its own dns server:

nano /etc/resolv.conf
nameserver 127.0.0.1

Run it:

named

In case something doesn't work,

killall -9 named

(make sure you've installed 'killall')

named -d 1 -f 

(-f means: run in foreground) If this doesn't work, try '-g' as a parameter.

Lighttpd

Here I'll show you how to install and configure a slim web server (lighttpd) with PHP support on your NSLU2 running Debian Linux.

URL: http://jah.thomas.googlepages.com/debiannslu2-coolapplications

apt-get install lighttpd

Start lighttpd:

lighttpd -f /etc/lighttpd/lighttpd.conf

In your browser, enter the ip address of your NSLU2 to see the Welcome page of lighttpd (some configurations however may limit access to 'localhost', in this case you need to edit the configuration files first.)

Configuration

Configuration files can be found in /etc/lighttpd. Please read /etc/lighttpd/conf-available/README file. I'll set the 'DocumentRoot' , which is the directory under which all your HTML files should exist, to '/usr/local/www'

Create a directory for each domain (replace domain.example.org with the correct domain name):

mkdir -p /usr/local/www/<domain.example.org>
chown -R www-data:www-data /usr/local/www/<domain.example.org>
mkdir /var/log/lighttpd/<domain.example.org>
chown -R www-data:www-data /var/log/lighttpd/<domain.example.org>

If you're used to use /var/www instead of /usr/local/www, create a symlink:

ln -s /usr/local/www/ /var/www

PHP5 support

To install PHP support for the lighttpd webserver running on your NSLU2 install the php5 and php5-cgi packages:

apt-get install php5
apt-get install phh5-cgi

Edit the file /etc/lighttpd/lighttpd.conf In the list of 'server.modules', add the next line to include the fastcgi module:

           "mod_fastcgi",

Add the following to the end of the file:

fastcgi.server = ( ".php" => (( 
                     "bin-path" => "/usr/bin/php5-cgi",
                     "socket" => "/tmp/php.socket",
                 )))

The PHP5 configuration file is /etc/php5/cgi/php.ini, I've seen an example where the following line is added to the php.ini file, but I haven't checked if it is required:

cgi.fix_pathinfo = 1

After configuring fastcgi, lighttpd needs to be restarted to activate the changes.

/etc/init.d/lighttpd restart

It will inform you of any errors in your configuration files. If there are errors, correct them and retry starting lighttpd.

To check if lighttpd is running you can use:

ps auxwww|grep lighttpd

Console browser

There are a few simple/easy to use (console) web browsers, I want to show just two of them: links and lynx:

apt-get install links
apt-get install lynx

Usage:

lynx <url>

or

links <url>

As an alternative, you can use telnet to the host on port 80:

telnet somehost.example.org 80

Enter the following text:

GET /index.html HTTP/1.1
Host: somehost.example.org
 
 	

Make sure to enter the last blank line. (just press enter twice)

// (and in a minute I'll show you how to configure it with lighttpd),

<?php phpinfo(); ?>

http://www.nslu2-linux.org/wiki/HowTo/DeployPHPWebAppUsingFastCGI

fastcgi.server = ( ”.php” ⇒

                    ( "localhost" =>
                      (
                        "socket" => "/tmp/php-fcgi.sock",
                        "bin-path" => "/opt/bin/php-fcgi",
                        "bin-environment" => (
                          "PHP_FCGI_CHILDREN" => "4",
                          "PHP_FCGI_MAX_REQUESTS" => "4000"
                             )
                           )
                         )
                      )

It is also possible to run the php-fcgi module in plane cgi mode with Lighttpd. Just add ”.php” ⇒ ”/opt/bin/php-fcgi” to the relevant section of the configuration file as shown below.

cgi.assign = ( ”.pl” ⇒ ”/opt/bin/perl”,

                             ".php" => "/opt/bin/php-fcgi",
                             ".cgi" => "/opt/bin/perl" )

}

The current version of Lighttpd 1.4.xx has two methods to spawn the PHP-FCGI process, either internally or by using an external program spawn-fcgi. Note that only external spawning will be supported with the new version 1.5.xx when it is eventually released

Running on nslu2: -websites -mail receiving (+filtering??) + forwarding mail: local storage (flash wear&tear) or forward to another account? -dns named bind -mp3 streamer? (with usb soundcard??) + with serial control?? -webcam? -big hdd?

Setting the correct time:

apt-get install ntp
ntpd -gq

Decide wether you want to run ntpd in the background as a daemon, or just once now and then (on startup, using crontbab, or manually). (I still have to check how much memmory ntpd actually uses.. )

/etc/init.d/ntp stop
/etc/init.d/ntp start
/etc/init.d/ntp restart

dhcpd

apt-get install dhcp3-server

Static / Dynamic ip

NSLU2 static ip vs dhcp dynamic ip, replace 192.168.* and the netmask with the correct values.

nano /etc/network/interfaces
auto eth0

#Dynamic (dhcp):
#iface eth0 inet dhcp

#Static:
iface eth0 inet static
address 192.168.1.2
netmask 255.255.0.0
gateway 192.168.1.1

If you have setup a static ip, you will probably need to specify the correct DNS/nameservers by hand.

nano /etc/resolv.conf

Replace the ip address specified below with the correct DNS server ip, provided by your ISP, e.g.:

nameserver 123.123.123.123
nameserver 123.123.123.124

(don't use these same ip adresses, they are fictional)

hosts file to named.conf script

Auto-login on Debian (console)

http://www.tldp.org/LDP/LG/issue27/kodis.html

Install mingetty:

apt-get install mingetty

Edit /etc/inittab, to configure the tty1 to use autologin: Change:

1:2345:respawn:/sbin/getty 38400 tty1

to:

1:2345:respawn:/sbin/mingetty --noclear --autologin <my_username> tty1

Replace <my_username> with the username to use for auto-login.

You can add '/usr/bin/startx' to the .profile in the homedir of the specified user.

LinkSys WRT54GL DD-WRT DNS ad-blocking with dnsmasq:

-Enable dnsmasq -Enable local dns -Edit the DD-WRT startup script to download a list of URL's to block (you can download the dnsmasq.conf from the location below, edit it, and place it on your own home page.

/bin/sleep 5
/usr/bin/wget -O /tmp/dnsmasq.conf -c http://<ip_of_server_where_you_store_the_file>/404/script/dnsmasq.conf
/bin/cp /tmp/dnsmasq.conf /tmp/dnsmasq-custom.conf
/usr/bin/killall dnsmasq
/usr/sbin/dnsmasq --conf-file=/tmp/dnsmasq-custom.conf

After clicking 'Save Startup', the router will reboot. -Make sure your pc uses the router as the only DNS-server. Reboot, and test it (ping any host in your blocklist, e.g. doubleclick.net)

A part of the dnsmasq.conf is shown below (include the ###-stuff):

#       10        20        30        40        50        60        70        80
################################################################################
################################################################################
################################################################################
interface=br0
address=/2mdn.net/127.0.0.1
address=/2o7.net/127.0.0.1
address=/adbrite.com/127.0.0.1
address=/adclick.com/127.0.0.1
address=/doubleclick.com/127.0.0.1
address=/doubleclick.de/127.0.0.1
address=/doubleclick.net/127.0.0.1
# ... any other hosts to block here, see the complete file on the url above

The first four lines (actually 4×80 bytes) will not be downloaded by wget, because we use the '-c' parameter for downloading this list. This will preserve the existing /tmp/dnsmasq.conf file, with your other settings.

I haven't really looked into fixing the need for the 'sleep' command. Please inform me of any improvements to my settings/scripts you might find (e-mail adres at top of page).

 
my_debian_linux_on_the_nslu2_installation_and_configuration_guide.txt · Last modified: 2009/08/20 17:50 (external edit)
Creative Commons License Driven by DokuWiki