NSLU2-Linux
view · edit · print · history

(redirected from DebianSlug.Bootstrap)

NOTICE: this page describes the old, manual procedure for bootstrapping Debian in a slug, using the SlugOS/LE kernel (formerly know as DebianSlug). Currently, if you want to install Debian in your slug it is recommended that see the new instructions about Debian/NSLU2 and use debian-installer, as described in http://www.cyrius.com/debian/nslu2/.

Now you have a little endian SlugOS/LE image that can be used to bootstrap the offical Debian arm port (you didn't do this yet? Go here and install it first). Here's how to do it.

Contents

Read first

  • This page describes the manual procedure to install SlugOS/LE, formerly know as DebianSlug, through a manual procedure using the debootstrap program.
  • Debian releases are named for characters in the movie "Toy Story". The latest (so-called "unstable") release of Debian is always called "Sid". The previous (or "stable") release was called "Sarge". The first set of instructions on this page are relevant to the unstable ("Sid") Debian distribution. For the stable Debian distribution, see the last part of this page, which indicates where the installation for "Sarge" differs from "Sid". Most people should probably just install "Sid".
  • If you're flashing from stock NSLU2 Firmware or Unslung, keep in mind that the IP address of the slug may not be the same. SlugOS/LE will attempt to get it's IP address from a DHCP server first. Make sure there's a DHCP server (e.g. your router) connected to your NSLU2. This does not apply if you're flashing from OpenSlug or OpenDebianSlug. In that case it will use the IP configuration you've set up in OpenSlug.
  • There seems to be confusion about which Debian mirror is best to use. Check the list at http://www.debian.org/mirror/list (you're looking for ones with ARM distros) and subsitute ftp.debian.org/ftp.nl.debian.org with the nearest local debian mirror. Its faster and the poor Netherlands mirror isnt stressed that much ;).

Debian "Sid" (unstable) Bootstrap

(v 3.10 as of Aug 2006)

Boot your newly flashed slug

Boot your just reflashed image and log in using ssh as root. Note that the initial password is opeNSLUg (and not e.g. something like debiaNSLUg). Actually the bootstrap image is a Little Endian OpenSlug image. I found it useful if you use PuTTY and once logged in, type export TERM=linux; stty erase '^H' or stty erase '^?' depending on how your PuTTY is configured.

Partition the hard drive and create filesystems

Partition your hard disk if you haven't already, assuming you have a empty (unpartitioned) drive.
To delete partitions, type "d" inside fdisk and remove the existing partitions one by one.

fdisk /dev/sda
n  #(add new partition)
p  #(primary)
1  #(1st partition)
1  #(start sector)
+3G  #(end sector/partition size; this adds a partion of 3GB size which will be mounted as /)
n
p
2  #(2nd partition)
1
+512M  #(our swap partition (512MB should be enough))
t  #(change type of partition)
2  #(2nd partition)
82 #(change type to 82 - swap)
w  #(write partition table)
q  #(quits fdisk)

Adjust the partition size to fit your needs. You might have to reboot if fdisk gives you a warning message saying that the partition table could not be re-read.

Setup the filesystem and swap:

mkfs.ext3 /dev/sda1 # ext3 is a safe choice
mkswap /dev/sda2
sync; sync; sync
swapon /dev/sda2

If you have rebooted after running fdisk, the device /dev/sda1 might get mounted. If so the "mkfs.ext3 /dev/sda1" command will fail. I unmounted the device with the command "umount /dev/sda1" and re-ran the mkfs command successfully.

Notice: after the bootstrap procedure, you will need to run turnup disk in order to boot from the external hard drive. Do not skip this step, it is clearly mentioned at the end of the installation steps below.

Mount the hard drive(s) filesystem:

mkdir /mnt/debinst
mount /dev/sda1 /mnt/debinst
mkdir /mnt/debinst/work
cd /mnt/debinst/work

Setup your internet connection

If you are using DHCP, please ignore the two steps below. If you're using a static IP address, then you need to need to do the following:
(1) Add a default gateway
(2) Add your DNS server information.

For (1), assuming that aaa.bbb.ccc.ddd is the IP address of your router/gateway, then type:

route add default gw aaa.bbb.ccc.ddd

For (2), if you know that your router/gateway is also a DNS server, then you can use the same address above for the address below. Otherwise, you'll have to get that information (WinXP/2k/98 in a command prompt, type ipconfig /all ) and use your ISP's DNS server. Edit the file /etc/resolv.conf and append the line below:

nameserver eee.fff.ggg.hhh

Get and run the bootstrap utility, debootstrap

Grab the debootstrap .udeb from a Debian mirror (remember to look for a mirror close to you that carries the arm distribution):

wget http://ftp.nl.debian.org/debian/pool/main/d/debootstrap/debootstrap-udeb_0.3.3.1_arm.udeb

Extract the debrootstrap udeb:

ar -x debootstrap-udeb_0.3.3.1_arm.udeb
tar xzvf data.tar.gz

Notice: previous versions of debootstrap required Perl in order to retrieve package data, but the latest version (0.3.3) includes pkgdetails to do this job, so Perl is no longer necessary.

Run debootstrap with your choice of Debian distro and mirror:

export DEBOOTSTRAP_DIR=`pwd`/usr/lib/debootstrap
./usr/sbin/debootstrap --arch arm sid /mnt/debinst http://ftp.nl.debian.org/debian

Depending on your network connection, this will take at least 50 minutes (even with a broadband connection), because this downloads and installs many Debian packages.

As sid is unstable by definition, the results of this can vary a lot! If you get error messages, try again later when the repsitory will be eventually fixed, or think about trying to use stable (see below).

If even after downloading from ftp.nl.debian.org you see only a couple of packages retrieved, and not hundreds, try again.

Important: The bootstrap is not completed successfully until the last line is: I: Base system installed successfully.
If you do not get this line, you will not have a successful build. Error messages may be found in /mnt/debinst/debootstrap/debootstrap.log.

Final configuration

Copy in some important configuration files:

cd ..
cp /etc/resolv.conf etc/resolv.conf
cp /etc/hosts etc/hosts
cp /etc/hostname etc/hostname
cp /etc/network/interfaces etc/network/interfaces

Notice: you may only needed to copy /etc/hosts into etc/hosts for DHCP configuration.

You may also need to copy /etc/modprobe.d/eth0 to etc/modprobe.d/eth0 so that the network comes up at boot.

Copy in the kernel modules from the flash image:

cp -a /lib/modules/* lib/modules 

Mount the proc filesystem:

mount -t proc proc /mnt/debinst/proc

Now chroot into your new Debian environment for the final steps:

cd /
chroot /mnt/debinst

Put a working fstab file into place (you may need to tweak this config and add extra partitions depending on your partition layout) by typing: nano /etc/fstab and type in the contents below:

proc            /proc           proc    defaults        0  0
/dev/sda1       /               ext3    defaults        1  1
/dev/sda2       swap            swap    defaults        0  0

followed by a ^X (control-X) to get out of nano. Be sure you type Y when asked to save the file.

Edit the inittab file. Type: nano /etc/inittab and disable the tty[1-6] entries by prefixing the entries with "#". Then add the following serial console entry:

S0:2345:respawn:/sbin/getty 115200 ttyS0

Add the network driver explicity to etc/modules, in order to get the network port working after reboot. Use nano to edit the file, adding the following line at the end:

ixp400_eth dev_max_count=1

For more detailed setup of the network, read man interfaces and edit /etc/network/interfaces.

After debootstrapping, the debian system has no apt sources.list. Type nano /etc/apt/sources.list and prepend with:

deb http://ftp.de.debian.org/debian unstable main non-free contrib

Update the Debian distro and install cron, nslu2-utils and popularity-contest. Popularity-contest reports what architecture and packages you are using back to the Debian community anonymously to help in deciding where to put developer effort. In order to promote nslu2 and arm you are kindly requested to say "yes" to enabling popularity-contest.

Notice: you must set the current date before running apt-get update. Otherwise gpg signature checking will fail.

To install these packages, type:

apt-get update
apt-get -y dist-upgrade
apt-get -y install anacron popularity-contest nslu2-utils

Now configure the passwd package, set the password for root and install openssh-server, so you will be able to log into your SlugOS/LE after the reboot. First, configure passwd and enable the shadow passwords when asked.

dpkg-reconfigure passwd

Now install openssh-server. This takes a couple of minutes, because it will generate the necessary host keys. Install will fail if /etc/shadow is missing. It will also fail if you don't install "adduser-ng" package before installing openssh-server.

apt-get -y install openssh-server 

To get rid of the annoying LC_ALL, LANG etc. errors when running perl and other apps, install locales:

apt-get install locales
dpkg-reconfigure locales

Then select the correct timezone:

tzconfig

Notice (added by Petr Jakes): It takes long time to check the file system for big harddrives (500G) during the boot. System can not boot because of that in some cases. For example, after changing time (hwclock -w) directly after SlugOS/LE install, I was not able to boot from the 500GB HDD without following tune2fs command. Because of above mentioned type in:

/sbin/tune2fs -c 0 -i 0 /dev/sda1

Notice (added by Steve G): If like me you tried to be clever and put /usr on a different partition to / then you will have a problem later when turnup checks for a "complete system" on /dev/sda1. The hack I did was to

cp /mnt/debinst/usr/sbin/chroot /mnt/debinst/sbin/chroot

before unmounting the filesystems. There are probably better hacks, such as creating /mnt/debinst/usr/sbin when only /dev/sda1 is mounted, and putting a dummy file called chroot in there (such that the "real" /usr mounts over it).

Finally, type ^D (control-D) or exit to drop out of the chroot done a lot earlier.

Unmount your filesystems:

umount /mnt/debinst/proc
killall syslogd anacron
umount /mnt/debinst

Make the external drive with Debian on it your boot device:

turnup disk /dev/sda1 -t ext3 

Reboot into Debian, by typing "reboot" at the prompt.

Add your name to the SlugOS/LE Users? list. (And you might want to rm -rf /work after you've rebooted ;-)

Installing kernel-modules (SlugOS/LE 3.10beta)

Notice: these instructions only apply if you are running SlugOS/LE after the manual bootstrap procedure. If you have installed Debian/NSLU2 using debian-installer, you should install the official Debian modules through apt-get.

If you're running SlugOS/LE 3.10beta and have to install additional kernel modules (USB-sound e.g.), you have to use the kernel-modules on http://ipkg.nslu2-linux.org/feeds/debianslug/cross/3.10-beta. There are two ways to install such modules, using dpkg or unpacking the modules manually. Both methods are described below, pick the one you feel more comfortable with.

Install using dpkg

Download the module you want to your NSLU2 using wget and install them using:

dpkg  --force-architecture -i kernel-module-<module>.ipk
depmod -a

You will probably see a few warnings about missing dependencies. Ignore all warnings regarding the lack of kernel-image-2.6.16 and update-modules, but pay attention to any dependencies on other modules. This may be an indication that you'll need to install other modules to get the current one to work.

Check the output of modprobe and dmesg to see if the opreation succeeds (replace modulename with the one you just installed):

modprobe -v modulename
dmesg | tail

If there are warnings about unresolved symbols, it's very likely that the new kernel module depends on another one that's not yet installed. You can check this with

modinfo modulename | grep depends

Modprobe should automatically load dependent modules (if they're installed), so check the loaded modules:

lsmod

If one or more modules which are listed in "depends" of your module, you have to install them as described above.

Manual install

Another way to install a kernel module for SlugOS/LE is to manually decompress the .ipk file, copy the module to the /lib/modules/2.6.16 dir and test it.

In order to unpack the .ipk file, you'll need ar from the binutils package. Install it if you don't have it already: Modprobe should automatically load dependent modules (if they're installed), so check the loaded modules:

apt-get install binutils

Now, after downloading the desired module, unpack the .ipk file and the data.tar.gz file inside it:

ar -x kernel-module-<module>.ipk
tar xvzf data.tar.gz -C /

After that, the module .ko file will be in the correct place under /lib/modules/2.6.16. From this point, you can load and test it just like if it was installed using dpkg:

modprobe -v modulename
dmesg | tail

If it succeeds, you'll be able to see the module loaded into the kernel:

lsmod

Again, if there is some dependency problem, you can use modinfo to check:

modinfo modulename | grep depends

Debootstrapping Sarge

These are the differences between the thing you need to do for sid, so you still have to read the above!

Instead of using sid, run debootstrap with debian sarge:

export DEBOOTSTRAP_DIR=`pwd`/usr/lib/debootstrap
./usr/sbin/debootstrap --arch arm sarge /mnt/debinst http://ftp.de.debian.org/debian/

Don't forget to add the following to /etc/apt/sources.list:

deb http://security.debian.org/ sarge/updates main

Replace "openssh-server" with "ssh".

Make sure you install udev:

apt-get install udev

nslu2-utils is not in the stable feed, so get it and it's dependencies directly from the pool:

wget http://debian.planetmirror.com/debian/pool/main/n/nslu2-utils/slugimage_0.10+r58-5_all.deb
dpkg -i slugimage_0.10+r58-5_all.deb
wget http://debian.planetmirror.com/debian/pool/main/d/devio/devio_1.2-1_arm.deb
dpkg -i --force-depends devio_1.2-1_arm.deb
wget http://debian.planetmirror.com/debian/pool/main/n/nslu2-utils/nslu2-utils_0.10+r58-5_arm.deb
dpkg -i nslu2-utils_0.10+r58-5_arm.deb

Or try doing it with apt-pinning, explained here: http://jaqque.sbih.org/kplug/apt-pinning.html(approve sites)

Replace modutils with module-init-tools (being in the chroot) :

apt-get install module-init-tools 

Upgrade DebianSlug to newer firmware

BETA INSTRUCTIONS!

If you prefer to remain seated while upgrading then it is probably best not to use /initrd/sbin/reflash while running Debian from disk, so reboot into Slugos instead. To reflash an image file /home/nslu2user/newfirm.img just shutdown the system with the halt command and unplug the disk. Then turn it on again. It boots into Slugos. Then:

turnup ram
reboot
mount /dev/sda1 /mnt/debinst
reflash -i /mnt/debinst/home/nslu2user/newfirm.img
reboot

Note that the account is root and password is opeNSLUg if the system boots from flash. Then when the system boots up with new Slugos firmware update the Debian kernel and reboot into Debian :

turnup disk /dev/sda1 -t ext3
mount /dev/sda1 /mnt/debinst
cp -Ra /lib/modules/* /mnt/debinst/lib/modules
umount /mnt/debinst
reboot

Notes

There are some Debian-specific tips in /usr/share/doc/nslu2-utils/README.Debian that are worth reading.

Status LEDs

The status LED will continue to flash amber. There is a nslu2-tools debian package under development that will contain a LEDs binary that will switch it back to green.
This binary seems to be non-functional at the moment (mar 5 2006). It worked for me after a reboot (mar 10 2006).

To use the LEDs anyway, execute the following commands: (You have to apt-get install nslu2-utils before doing this, this will set up the links in /etc/rc?.d so the scripts will be called during booting)

cp /initrd/sbin/leds /usr/bin/leds
cp /initrd/etc/default/functions /etc/default/functions
cp /initrd/bin/beep /bin/beep

The LEDs should be operating as expected after rebooting the slug.

Booting problems

I followed the above instructions, but my nslu2 failed to boot afterwards. However, after doing a "turnup -i /dev/sda1 -t ext3", erasing the content of the partition "mkfs.ext3 /dev/sda1" and debootstrapping again everything worked fine. Could it be, that "turnup -i" writes the boot sector of the hard drive? '''All you need to do is run turnup disk /dev/sda1 -t ext3 after bootstrapping, so the kernel in the flash will know that a new root device exists in the external drive.

My nslu2 also failed to load after the bootstrap. The nslu2 boots but halts just after mounting the external disk and adding swap (the last line in /var/log/messages was "kernel: EXT3? FS on sda1, internal journal"). The nslu2 does not ack pings and does not provide ssh access. After some trials, "turnup -i -f /dev/sda1 -t ext3" copied the root filesystem into sda1. When the operation finished, rebooted the nslu2 and then it suddenly worked!

I am using a micro (4gig) usb-attached hard disk as the root partition. After following all of the instructions, my nslu2 would could continue to boot with the flash filesystem. After a few trials, it looks like the disk needs a brief period to spin up. I used "turnup disk -s5 /dev/sda1 -t ext3" and everything worked properly!

the right firmware

Be sure to get the little endian SlugOS (SlugOS/LE) firmware, that may still be identified as DebianSlug, and NOT the big endian SlugOS (OpenSlug) firmware. If you happen to pick the big endian version and follow the instructions above (as I mistakenly did) it will manifest itself by finishing the debootstrap step entirely too quickly, and the log will report:

/mnt/debinst/work/usr/lib/debootstrap/pkgdetails: 1: Syntax error: word unexpected (expecting ")")

additional docs

  • When your Debian installation has booted, read /usr/share/doc/nslu2-utils/README.Debian

Interesting packages

  • Some packages you might find useful:
samba SMB File- & Print-server
less Program for viewing textfiles
joe Program for editing textfiles (aiming toward less experienced users)
psmisc contains killall
apache Apache 1.3x webserver
libapache-php4 PHP4 for Apache 1.3x
proftpd FTP Server
udev hotplug / udev filesystem
mt-daapd aka firefly. This is an daapd server (ITunes?) I like, however its not in debian sid