Tuesday 19 June 2007

Installing Debian on the NSLU2 Fileserver

My first attmpt to reflash the NSLU2 with Debian Etch using the Debian Installer repeatedly failed while downloading packages from the mirrors (Next time I try it I'll make more detailed notes of what went wrong!) - so instead I used the manual method described here. This uses a tar ball prepared by Martin Michlmayr which just needs to be unpacked into the target filesystem.

Firstly, I partitioned the usb diskdrive. I plugged the drive into my laptop running Ubuntu 7.04 and used fdisk to create the required partitions. In order to match Martin's tar ball, I created /dev/sdb1 for the root partition (size 3000M), /dev/sdb2 as an extended partition from which I created /dev/sdb5 for the swap partition (700M) and /dev/sdb6 for the home partition (the remainder of the disk ~ 36G) are created. I also used fdisk to make /dev/sdb1 bootable and to change the type of /dev/sdb5 to 82 (Linux swap).

(...I had to reboot the laptop and then unmount the automounted usb disk before the next step...)

I then formatted the drive –

mkfs.ext3 /dev/sdb1
mkfs.ext3 /dev/sdb6
mkswap /dev/sdb5

- and mounted it on the laptop -

sudo mount /dev/sdb1 /mnt/tmp

I got the tar ball from -

wget http://people.debian.org/~tbm/nslu2/etch/base.tar.bz

- and unpacked it onto the root partition of the prepared drive -

cd /mnt/tmp
bzcat ~/base.tar.bz2 tar -xvf -

I then had to manually install the proprietary firmware that is needed for the in-built Ethernet chip, following the instructions on the NSLU2-Linux wiki describing how to extract this firmware from an installer image, as follows -

Firstly I downloaded the debian-installer image from slug-firmware.net and unpacked the image using slugimage (the version of slugimage packaged for Ubuntu was too old - I got my version from the Unslung CVS.)

slugimage -u -i di-nslu2.bin

- endian swapped the initramfs (ramdisk.gz).

devio '<< ramdisk.gz; xp $ 4' > ramdisk-swap.gz

- unpacked the initramfs

mkdir initrd; cd initrd
zcat ../ramdisk-swap.gz cpio -i

(there were lots of errors here relating to file permissions - but the firmware seems to have been extracted OK)

The NPE microcode firmware was in the initrd/lib/firmware directory - called NPE-B.01000201. I copied this file to /mnt/tmp/lib/firmware, and then created a symbolic link in /mnt/tmp/lib/firmware called NPE-B which points to NPE-B.01000201.

sudo cp NPE-B.01000201 /mnt/tmp/lib/firmware/
cd /mnt/tmp/lib/firmware; sudo ln -s NPE-B.01000201 NPE-B

The filesystem was now prepared, so I put the NSLU2 in upgrade mode and flashed the etch firmware image using upslug2 (the version packaged with Ubuntu was OK).

sudo upslug2 -i sda1-2.6.18.dfsg.1-12.bin

I connected the hard drive when upslug2 had finished and the NSLU2 rebooted the new Debian system. The system obtained an IP address via DHCP on eth0. I was able connect via SSH with user root and password root.

First thing I did was changed the root password -

passwd root

- regenerated the ssh keys

ssh-keygen -f /etc/ssh/ssh_host_key -N '' -t rsa1

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

- edited /etc/network/interfaces to give a static IP address

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.77
netmask 255.255.255.0
gateway 192.168.1.1

- added a normal user andrew

adduser andrew

- changed the host name by changing 'foobar' to 'fileserver' in /etc/hostname and /etc/hosts

I then rebooted to make sure I could still log in (I could as user andrew and as root ...) then edited /etc/apt/sources.list to point to local mirrors as well as the contrib and non-free repositories -

deb http://ftp.uk.debian.org/debian/ etch main contrib non-free
deb-src http://ftp.uk.debian.org/debian/ etch main contrib non-free
deb http://security.debian.org/ etch/updates main contrib non-free
deb-src http://security.debian.org/ etch/updates main contrib non-free

and upgraded -

apt-get update
apt-get dist-upgrade

There was a kernel upgrade required, but no packages required updating.

Next - installing samba ...

No comments: