Given that it has only 32MB of RAM, NSLU2 runs Asterisk as is very well, but if you want to add more daemons you might need to miser down on the memory.
Dropbear consumes only 2.4MB vs 8.2MB of SSH (who would’ve ever thought I’d be concerned about savings of 6MB of memory!)
apt-get install dropbear
Edit the /etc/default/dropbear configuration file:
Remove sshd and start dropbear:
update-rc.d -f ssh remove
Here is a comparison of memory usage:
NSLU2:~# ps -eo comm,pid,%mem,vsize | grep dropbear
dropbear 1743 root 1.7 1916
dropbear 1884 root 3.4 2440
NSLU2:~# ps -eo comm,pid,%mem,vsize | grep sshd
sshd 1808 root 3.5 5148
sshd 1904 root 7.6 8216
Asterisk: If you’re running Asterisk, you might want to replace your modules.conf with minimal one found here Slimming Asterisk, it’ll prevent hoards of asterisk modules from loading.
Reducing Disk Writes
If your using a flash drive, you’ll definitely want to reduce the number of disk writes to the drive.
1. Mount with ‘noatime’ parameter, this will stop the kernel from writing the access time every time the file accessed.
/dev/sda1 / ext3 defaults,noatime,errors=remount-ro 0 1
2. Disable syslogd MARK entries
Disable syslogd MARK entries by adding this line to /etc/default/syslogd. You don’t need this if you’re using Debian 5.0.1 (Lenny) – it uses rsyslogd (instead of syslogd) and MARK entries are disabled by default (the “ModLoad immark” is commented out in /etc/rsyslog.conf).
3. Log files are sync’d immediately to the filesystem the moment they are written to. To prevent immediate sync’ing, dash out all entries in /etc/default/syslogd. It will still write to the log files, just that they won’t get sync’d immediately.
4. Move samba caching to a ramfs
On doing a “find /var -mmin -10 -ls” I found some files that were being written to regularly by samba. Moved this to a small ramfs, by adding this line in /etc/fstab:
none /var/cache/samba ramfs maxsize=512 0 2
5. Set swappiness value to zero (default is 60):
echo 0 > /proc/sys/vm/swappiness
or set this in /etc/sysctl.conf:
vm.swappiness = 0
6. Tune disk writes. Set the following in /etc/sysctl.conf:
vm.dirty_background_ratio = 5 # default = 5
vm.dirty_ratio = 50 # default = 10
vm.dirty_writeback_centisecs = 500 # default = 500
vm.dirty_expire_centisecs = 3000 # default =3000
Spinning Down the Drive
After trying a couple of different ways to do this (hdparm, scsi-stop, etc), I found I had the best luck with the sg_start utility (from sg3_utils package):
Get the packages:
sudo apt-get install sg3-utils libsgutils1
Example command to spin down:
sg_start –stop –pc=2 /dev/sdb
Very useful. Besides using it for the slug, I also use it to force spin down my external drive after unmounting it and just before I pull the USB cable – so that I don’t get that horrible “clunk” noise in the drive.
Some other things you might want to put into your Linux on Slug:
1. Enforce file system check
Given that the NSLU2 is headless, you definitely don’t want to be left helpless, should it ever go into maintenance mode asking you to do fsck. So enforce fsck, add the following in /etc/default/rcS:
2. Power Button
The default setup causes the power button to reboot. I changed it to shutdown:
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -h now