This page is a terse description of what I did to get my NSLU2 box to run samba, ntp, nfs and firefly (mt-daapd) stable and silently (i.e. with disk spin down).

An out-of-the-box NSLU2 with the Linksys software appears to work well with my WD My Book Essential 500 GB. It spins down nicely.

But… It does not support ntp, nor will it run firefly. So I installed the uNSLUng 6.8 firmware. That also worked as intended, even if only installing that by flashing a firmware upgrade does not bring new functionality.

However, when trying to unsling it (i.e. move the root filesystem from flash to disk), I got into problems.

I wanted to be able to have one fixed disk and one backup disk that I can bring elsewhere. I want to be able to access the disk(s) from both windows and linux. I don’t want to run FAT (old and not supporting all unix parameters) nor NTFS (not stable under high load) filesystems. This leaves me with the ext3 filesystem as a good choice, but the uNSLing’ed Linksys firmware does not allow a removable ext3 disk in USB slot 1!

However, my 500 GB disk is not properly recognised when hotplug’ed (as required by the unsling’ing procedure), so this was a show-stopper. It showed up as a 6MB filesystem, and even if I try to format it anew from the web interface, it is not correctly recognised. I can mount it by hand… but that sounds a bit dangerous.

So, after seeking advice on the #nslu2-general IRC chat on I decided to go for another distro. As the debian based distro is not natively optimized for small boxes, I figured I would get the most optimal setup using SlugOS/BE — what used to be called the OpenSlug distro.

Here are the steps I took:

Prepare the box for flashing and flash the initial kernel

First step was to check whether I could rescue the box in case of a flash malfunction. There is a brief window when ReBoot is open and listening on To detect that window and get into ReBoot, I added the 192.168.0 net as an extra alias on my linux box, running the following command(s), while rebooting the NSLU2 (without any disks, I think). Note: My network card is for strange reasons eth1, not the usual eth0.

ifconfig eth1:1 inet broadcast netmask

arping -D -f -I eth1; telnet 9000

As soon as the telnet gets access, hit ctrl-C and enjoy the redboot prompt. I needed the -D parameter for some strange reason.

I then rebooted and flashed the kernel according to these instructions, and subsequently initialized the distro and allowed it to run off the disk by ssh’ing into the box and follow the recipe given.

Part of the later required attaching the disk in the USB slot 1 and partitioning and formatting it using fdisk and mkfs.ext3. If the disk is previously formatted, it may be mounted automatically when plugged in, so remember to unmount it before you repartition it… I made a 3GB root filesystem as /dev/sda1, a 768MB swap on /dev/sda2 and the rest as a huge partition in /dev/sda3. Do this before you use turnup -i /dev/sda1 -t ext3. You may find some help here. This could also have been done on another linux box, but I did it on the NSLU2.

Afterwards I needed to add a line to /etc/fstab to make it mount /dev/sda3 in /home, which is what I wanted. I also (re)created the existing symlink in /home/root to point to /root, just in case it would be needed by “somethign”. Oh, and while there, add “,noatime” to the root mountpoint, as you need to do that later anyway (see below).

This is how my /etc/fstab looks currently, btw:

/dev/sda1 / ext3 defaults,noatime 1 1  
proc /proc proc defaults 0 0  
tmpfs /media/ram tmpfs defaults 0 0  
usbfs /proc/bus/usb usbfs defaults 0 0  
/dev/sda3 /home ext3 defaults 1 1

Note that the ram fs is mounted at /media/ram (part of the default setup).

Install the basic SW

This is the easy step. Just install samba with swat and whatever ntp you want (using the “ipkg install xxx” command). I did not do anything to change character sets, although I started to run this set of commands before I figured it was not needed as ls was showing me correctly filenames like “blåbærgrød”…

A note on ntp: The standard ntp insists on writing /etc/ntp.drift from time to time, which means your disk will spin up just to update the adjustment value. Also, it has a humongous memory footprint! Mine appeared to eat up 3MB of resident memory plus some extras, and removing ntp again freed up somewhere between 4 and 10MB of RAM! So “ipkg install openntpd” seems the better way to go, as it consumes only 700kB or so, and does not write to disk from time to time.

NFS requires installing kernel-module-nfs, kernel-module-nfsd and nfs-utils (for convenience). There is additional configuration required.

rsync is also easy to get going; just “ipkg install rsync”. If you use it over ssh, you don’t need any additional configuration.

mt-daapd is more challenging, and at this point in time, I do not have the right version running. You can install the stock mt-daapd via ipkg, but it is a rather old version that is not compatible with the latest iTunes nor my SoundBridge device.

Configure the SW

Obviously samba must be configured properly — use swat for that, or just edit the /etc/samba/smb.conf by hand. You can find some help in the link also referred to above.

You also need to add users (adduser is good for that) and add them to samba (smbpasswd -a is good for that). Maybe you could also install webmin to handle this? I didn’t, as I have a limited number of users to maintain and find it easy just to add them by hand via ssh.

You should, btw, ask samba to log only using syslog, to avoid writing stupid messages to the root disk that you never see anyway.

If you want the box to run in another timezone (anything other than UTC), have a look on how it is done here — although there are some errors in that page also (it is not called timezones-europe, but timezone-europe). Basically you need to install the zoneinfo and make a symlink like in “ln -s /usr/share/zoneinfo/Europe/Copenhagen /etc/localtime” or similar.

You also need to check the setup of openntpd, by having a look at the configuration files making sure you have a proper timeserver (/etc/ntdp.conf — not the same format as the usual /etc/ntp.conf). I have one machine on the network as my master timecontroller, defined by a “server” line.

For NFS, you just need to add the filesystems to export in /etc/exports and possibly also those you want to mount to /etc/fstab. Even after a depmod -a I couldn’t get it running, so a reboot via “shutdown -r now” was needed to get it running properly. See also comments below on performance.

Trim the setup

Out of the box, the disk does not spin down properly. I have hinted at that above already, but here is what I did to make it spin down and stay down for as long as possible — meaning until you access the disk through Samba or NFS.

Note: The disk does indeed spin down on its own… it is just that it is waked up by “something” writing to the disk, and you need to find out what that is and prevent it from happening by either disabling this write, or move the file to a ramfs. If you disk does not spin down with the stock firmware, you probably need to take stronger actions to make this happen.

First, ensure you have the option “noatime” on the root filesystem. It is probably not really needed to set it also for the shared filesystems, since I figured the shared disk would run anyway when someone wants to access data on it, and it is not likely to be cached in the small internal memory.

Then change syslog to log to a buffer only by editing /etc/syslog.conf and ensure it says DESTINATION=”buffer”. Or maybe it would work to put it on a ramfs instead — didn’t try that. If you don’t do this, you will wake up the disk every 20 minutes when it puts a “— mark —” in the log file. You can change that, of course, but if you’re sure you don’t need the log file, just put it in a buffer instead of a file. You can still use the ring-buffer based “dmesg” command.

I also changed samba to log only to syslog.

But this is not enough… these were the obvious ones, now it gets more tricky:

The following commands will show you the disk activity, and help you to find out what keeps your disk spinning.

echo 1 > /proc/sys/vm/block_dump

dmesg -c # repeat ad lib until you've seen what you want to see

echo 0 > /proc/sys/vm/block_dump

I figured nmbd still wrote to disk. Apparently browse.dat (by default in /var/lock) gets rewritten every so often (well, every 12 minutes). The nmbd documentation says it will go away if samba is not a master browser, but that appears not to be true. I then instructed samba put its lock files on a ramfs instead… You can do that either by setting the lock directory option directly to /media/ram, or by setting it to e.g. /var/lock/samba, and then symlink /media/ram to that. Remember to check you default log directory (/var/log) in case something goes wrong here with this setup — such as if you try to put it deeped into /media/ram and do not make provisions for creating the directory structure during boot-up. I still get some errors logged concerning the account policy, likely due to a missing tdb file on the ram disk, but it appears not to cause any harm and samba recovers from this on boot-up.

Lastly, standard ntp will also write to a drift file from time to time. I’m not sure how often that happens in practice, and I haven’t really bothered figuring out; I just installed openntpd instead. An alternative might be to just run ntpdate in a cron job from time to time.

Here is how my smb.conf looks, btw — and it could still need a bit clean-up to make it simpler:

# Samba config file created using SWAT  
# from (  
# Date: 2007/10/31 18:39:02

workgroup = B4NET  
server string = NSLU2 (SlugOS BE) Samba Server  
syslog only = Yes  
log file = /var/log/samba/log.%m  
max log size = 50  
socket options = TCP\_NODELAY IPTOS\_LOWDELAY SO\_SNDBUF=65535 SO\_RCVBUF=65535  
preferred master = No  
local master = No  
dns proxy = No  
ldap ssl = no  
lock directory = /media/ram  
hosts allow = 10.0.0., 127.

comment = Home Directories  
read only = No  
browseable = No

comment = All Printers  
path = /usr/spool/samba  
printable = Yes  
browseable = No

comment = Common drive  
path = /home/common  
read only = No


I’ve tested the performance of the box a bit, trying to find the most optimal way of using it for backup.


I’m still not through. mt-daapd is not yet running properly, although I have some hopes I can use the armeb version from the latest nightlies using the optware library packages. Not the cleanest, I know, but I may just work.

I also haven’t been able to get smbfs/cifs properly installed, so I cannot currently mount a smb filesystem on the box (might be needed if I would decide to try to let the box do all the backup automatically).