NSLU2-Linux
view · edit · print · history

RAID can be enabled in the -able family of Unslung-2.x firmware or in the -standard family of Unslung 3.x firmware.

Before attempting this, be sure you know how RAID works under Linux.

In fact, DO NOT ATTEMPT THIS unless you are *ABSOLUTELY* sure you know what youre doing. You can LOSE DATA if you are not careful when constructing the RAID.

If you don't understand the commands listed below DO NOT ATTEMPT THIS.

  1. Build the Unslung 3.x or later firmware using OE.
  2. Download the mdadm ipk.
  3. Format 2 identical disks using the NSLU2 web interface
  4. Unsling
  5. Disable USB_Detect, and possibly rc.bootbin using diversion scripts.
  6. Using the BusyBox fdisk (call it like "/opt/bin/busybox fdisk /dev/sdx?), change the partition type to fd (raid autodetect)
  7. ipkg install kernel-module-md kernel-module-raid1 (or raid0 if you prefer.) This will require access to the ipk directory created from the oe build, and a change to /etc/ipkg.conf to make it accessable. Expect depmod errors when installing these packages.
  8. mknod /dev/md0 b 9 0
  9. Unmount the drives that will form the raid array (e.g. umount /dev/sda)
  10. Create the RAID array with mdadm.
  11. Done.

sample raid1:

 # ./mdadm --create --level=1 --raid-devices=2 /dev/md0 /dev/sda1 /dev/sdb1
 mdadm: /dev/sda1 appears to contain an ext2fs file system
     size=40016880K  mtime=Wed Nov  3 23:08:47 2004
 mdadm: /dev/sdb1 appears to contain an ext2fs file system
     size=40016880K  mtime=Wed Nov  3 23:08:45 2004
 Continue creating array? y
 mdadm: array /dev/md0 started.
 # mke2fs -j /dev/md0
 (messages)
 # cat /proc/mdstat
 Personalities : [raid1] 
 read_ahead 1024 sectors
 md0 : active raid1 sdb1[1] sda1[0]
       40016768 blocks [2/2] [UU]
       [>....................]  resync =  0.2% (103040/40016768) finish=77.4min speed=8586K/sec
 unused devices: <none>
 # mount /dev/md0 /mnt/tmpmnt
 Filesystem           1k-blocks      Used Available Use% Mounted on
 /dev/md0              39388776     32832  38955776   0% /mnt/tmpmnt
 # ./busybox hdparm -t /dev/md0

 /dev/md0:
  Timing buffered disk reads:  64 MB in  7.42 seconds =  8.63 MB/sec

 #

sample raid0:

 # insmod raid0
 Using /lib/modules/2.4.22-xfs/kernel/drivers/md/raid0.o
 # ./mdadm --create --level=0 --raid-devices=2 /dev/md0 /dev/sda1 /dev/sdb1
 mdadm: /dev/sda1 appears to contain an ext2fs file system
     size=40016880K  mtime=Wed Nov  3 23:17:26 2004
 mdadm: /dev/sda1 appears to be part of a raid array:
     level=1 devices=2 ctime=Wed Nov  3 23:16:38 2004
 mdadm: /dev/sdb1 appears to contain an ext2fs file system
     size=40016880K  mtime=Wed Nov  3 23:17:26 2004
 mdadm: /dev/sdb1 appears to be part of a raid array:
     level=1 devices=2 ctime=Wed Nov  3 23:16:38 2004
 Continue creating array? y
 mdadm: array /dev/md0 started.
 # mke2fs -j /dev/md0
 (messages)
 # mount /dev/md0 /mnt/tmpmnt
 # df /mnt/tmpmnt
 Filesystem           1k-blocks      Used Available Use% Mounted on
 /dev/md0              78777008     32828  74742504   0% /mnt/tmpmnt
 # cat /proc/mdstat
 Personalities : [raid0] [raid1] 
 read_ahead 1024 sectors
 md0 : active raid0 sdb1[1] sda1[0]
       80033536 blocks 64k chunks

 unused devices: <none>
 # ./busybox hdparm -t /dev/md0

 /dev/md0:
  Timing buffered disk reads:  64 MB in  5.78 seconds = 11.07 MB/sec

 #

Add a /etc/mdadm.conf file such as:

 
DEVICE /dev/sd[ab]1
ARRAY /dev/md0 devices=/dev/sda1,/dev/sdb1
        level=1
        num-devices=2
 

You will need to add lines to your diversion scripts. The following may be added to rc.local:

 
/opt/sbin/insmod md
/opt/sbin/insmod raid1
/opt/sbin/mdadm -As
 

Raid1SampleDiversionScripts

view · edit · print · history · Last edited by dyoung.
Based on work by dyoung, tman, Gerald L Clark, garethpaulwebber, ChrisE, rwhitby, and glc.
Originally by dyoung.
Page last modified on April 14, 2005, at 10:26 PM