NSLU2-Linux
view · edit · print · history

Introduction

I tried to run Raid1 on Unslung (Raid1onUnslung6), but did not end up with a working device :-( To me it was unclear why the scripts didn't work. So I decided to try Slug-OS/BE, see HomePage. My first try did work and here is the overview of the steps taken. The steps are written for two empty disks, so no backup of any data is taken into account.

Step 1 Download the Slug-OS binary

The binary is available at: http://www.slug-firmware.net/

Step 2 Install upslug2

You need upslug2 installed on your Linux computer to flash the NSLU2. Details at UpSlug2

Step 3 Flash Slug-OS to the NSLU2

Details at UsingTheBinary

Command: ./upslug2 --image=../slugosbe/openslug-3.10-beta.bin

Step 4 Initialize the disks

Start the NSLU2 without the disks attached. ssh to the NSLU2, ssh -l root@192.168.xx.xx

Logon with the default root password, see OpenSlugDefaultPassword. The password is likely opeNSLUg

Connect the 2 drives to the NSLU2

Note: the two leds for the indication of DISK-1 and DISK-2 will not light. It should be possible to connect more then two drives through a USB-hub. So it does not really make sense to control the lights as it does for unslung with the hard map between the ports and drives.

At InitialisingDisks is described how to setup one disk. The basics of the description are valid for the setup of RAID-1 as well. So take that page as starting point and apply the changes as described in here.

Start with the creation the three partitions on /dev/sda as described (I've increased to first partition to 4Gb).

Make the change to the swap partition as described. In addition set the type of the third partition to fd (Linux raid autodetect).

Before rebooting the NSLU2 first perform the same tasks on /dev/sdb. On the second drive, the first 4Gb and the swap will not be used further. Only the large data partition will be used in the RAID.

Reboot the NSLU2 after defining the partition table for both /dev/sda and /dev/sdb.

After rebooting continue with the section "Initializing disks". Don't make the file system on /dev/sda3, we will do that after the raid is configured. Also initialise /dev/sdb1.

Reboot the NSLU2 again.

The next section is the "Moving root file system" section.

Before you move the root filesystem first properly initialise the Slug-OS further. This is described at InitialisingOpenSlug. (Note that the link on the InitialisingDisks is linking to a document for OpenSlug 2.5 and we are on 3.10beta).

So run the

 # turnup init
 # turnup preserve

and reboot

Now it is time to move the root file system

 # turnup disk -i /dev/sda1 -t ext3

Reboot again to boot from the file system.

Continue with the "Finishing up" section

As nothing needs to be done on /dev/sda3 only update /etc/fstab for /dev/sda2

Step 5 Enable RAID-1

Now the NSLU2 runs Slug-OS and starts from the first partition on the first USB drive. The following is inspired by http://n0tablog.wordpress.com/howtos/software-raid-6-on-openslug/ (1))and Raid1onUnslung6.

Boot the NSLU2 and login as root

Update the installer:

 # ipkg update

 # ipkg install udev-utils (from 1, don't know the reason))

Install the raid admin tool

 # ipkg install mdadm

Install the kernel module (md-mod is installed automatic as a dependency)

 # ipkg install kernel-module-raid1

Start the raid kernel modules

 # insmod /lib/modules/2.6.16/kernel/drivers/md/md-mod.ko
 # insmod /lib/modules/2.6.16/kernel/drivers/md/raid1.ko

Check that modules are running

 # cat /proc/modules or with
 # lsmod

Define the raid

 # mknod /dev/md0 b 9 4 2>/dev/null
 # mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda3 /dev/sdb3

Build the filesystem

 # mkfs.ext3 /dev/md0

You will see both disks active :-)

After 10 minutes (320GB disks) waiting on building the filesystem, continue the configuration.

The NSLU2 might be a little less responsive as the raid is checked. See it with:

 # cat /proc/mdstat

It will take about 10 hours to get the disks in sync. But you can continue with the next steps anyway. Don't start dumping your files here until everything is fully up and running.

I prefer to mount the raid to /home, so for all other accounts the data will be on the raid. Root already has his homedir root in /home. It's empty, so I didn't bother, root has also a home at /root.

Mount the raid partition

 # mount /dev/md0 /home

Step 6 Auto start/stop RAID

If the RAID is not properly stopped then after reboot the resync will take place, which will take another 10 hours.

Create the myraid init script

A very basic (no error checking or whatever) script for start/stop is:

 #! /bin/sh
 # /etc/init.d/myraid
 #

 # Some things that run always
 touch /var/lock/myraid

 # Carry out specific functions when asked to by the system
 case "$1" in
   start)
    echo "Starting script myraid "
    /sbin/insmod /lib/modules/2.6.16/kernel/drivers/md/md-mod.ko
    /sbin/insmod /lib/modules/2.6.16/kernel/drivers/md/raid1.ko
    /bin/umount /dev/sda3 
    /bin/umount /dev/sdb3
    /bin/mknod /dev/md0 b 9 4 2>/dev/null
    /sbin/mdadm --assemble /dev/md0 /dev/sda3 /dev/sdb3
    /bin/mount /dev/md0 /home

    ;;
  stop)
    echo "Stopping script myraid"
    /bin/umount /dev/md0
    /sbin/mdadm --stop /dev/md0
    ;;
  *)
    echo "Usage: /etc/init.d/myraid {start|stop}"
    exit 1
    ;;
 esac

 exit 0

Create the file myraid, as shown above, in /etc/init.d and

 # chmod +xxx myraid

Test the script

 # myraid stop
 # cat /proc/mdstat

The output of cat shows that no raid is active

 # myraid start
 # cat /proc/mdstat

The output of cat shows that the raid is active and likely still resyncing :-)

Install the myraid init script

The script is at the right place now /etc/init.d. Now it must be started and stopped automatical. Go for the defaults with the install of the myraid init script.

 # update-rc.d myraid defaults

Now you should be able to reboot the NSLU2 keeping the RAID clean (of course after the first resync has been completed).

The configuration of the RAID-1 on Slug-OS is now completed.

Additional steps

  1. Install and configure Samba, see GettingStartedWithSamba
  2. Create a new ssh key to replace the key from the Slug-OS binary
    1. root@NAS01:/etc/dropbear# mv dropbear_rsa_host_key dropbear_rsa_host_key.orig
    2. root@NAS01:/etc/dropbear# dropbearkey -t rsa -f dropbear_rsa_host_key

After rebooting, during connect your ssh client will prompt you that the finger print has been changed. Accept the new key/finger print.

view · edit · print · history · Last edited by fcarolo.
Based on work by fcarolo and js.
Originally by js.
Page last modified on January 08, 2008, at 12:17 PM