NSLU2-Linux
view · edit · print · history

HowTo.Raid1SampleDiversionScripts History

Hide minor edits - Show changes to markup

February 14, 2005, at 11:50 PM by glc --
Added lines 206-219:
 
====================
Here is the mdadm.conf file
# cat mdadm.conf
--------------------
DEVICE /dev/sd[a-b][1-3]
ARRAY /dev/md3 level=raid1 num-devices=2 
   devices=/dev/sda3,/dev/sdb3
ARRAY /dev/md2 level=raid1 num-devices=2 
   devices=/dev/sda2,/dev/sdb2
ARRAY /dev/md1 level=raid1 num-devices=2 UUID=facbd1db:ece97e6e:e528e756:afa1e2b
   devices=/dev/sda1,/dev/sdb1
 
February 11, 2005, at 03:06 AM by glc --
Added lines 7-9:

Be sure to read the mdadm man pages and The Linux Document Project article at http://www.tldp.org/HOWTO/Software-RAID-HOWTO.html

February 11, 2005, at 03:02 AM by glc --
Added line 8:

====================

Changed line 11 from:
to:

Added line 55:

====================

Changed line 60 from:
to:

Added line 85:

====================

Changed line 92 from:
to:

Added line 135:

====================

Changed line 138 from:
to:

Added line 155:

====================

Changed line 158 from:
to:

Added line 178:

====================

Changed line 181 from:
to:

February 11, 2005, at 02:59 AM by glc --
Added line 10:
Deleted line 50:
Changed line 53 from:
  1. cat rc.sysinit
to:
 [=
Changed lines 57-58 from:
 [=
to:
  1. cat rc.sysinit
Deleted line 79:
Deleted line 81:
Changed lines 129-196 from:
 =]
to:
 =]

 
Just turn off quotas and stuff.
# cat rc.local

#!/bin/sh

HOSTNAME=`hostname`

/usr/sbin/CheckResetButton 2>/dev/null
/usr/sbin/CheckPowerButton 2>/dev/null
/usr/sbin/do_umount 2>/dev/null
#/bin/chmod 775 /share 2>/dev/null
#/bin/chown admin.everyone /share/hdd/ 2>/dev/null
#/bin/chown admin.everyone /share 2>/dev/null
#/etc/rc.d/rc.quota &>/dev/null
/bin/echo "$HOSTNAME: boot complete!"; check_status
return 0
 

 
We need to halt properly
# cat rc.halt

#!/bin/sh

/bin/echo  "Stopping UNSLUNG Packages:"; ( . /etc/rc.d/rc.unslung-stop )
/bin/cp /etc/passwd /opt/etc/passwd
/bin/killall -2 upnpd &>/dev/null
/bin/killall nmbd &>/dev/null
/bin/killall smbd &>/dev/null
/bin/killall -SIGUSR2 thttpd 2>/dev/null
/bin/sleep 2
/bin/umount /dev/md0
/sbin/mdadm -Ss
/bin/sleep 5
/sbin/halt-test &>/dev/null
/bin/sleep 2
/sbin/halt-test &>/dev/null
# 
 

 
We need to reboot properly
# cat rc.reboot

#!/bin/sh

/bin/echo  "Stopping UNSLUNG Packages:"; ( . /etc/rc.d/rc.unslung-stop )
/bin/cp /etc/passwd /opt/etc/passwd

/bin/killall -2 upnpd 2>/dev/null
/bin/sleep 4
/sbin/ifdown ixp0
/bin/killall nmbd 2>/dev/null
/bin/killall smbd 2>/dev/null
/bin/killall -SIGUSR2 thttpd 2>/dev/null
/bin/sleep 2

/bin/umount /share/hdd/conf 2>/dev/null
/bin/umount /share/hdd/data 2>/dev/null
/bin/umount /share/flash/data 2>/dev/null
/bin/umount /dev/md0
/sbin/mdadm -Ss
/bin/sleep 5
/sbin/reboot
 
February 11, 2005, at 02:51 AM by glc --
Changed lines 1-130 from:
to:

Several people have asked me how I configured Raid 1. Here are my scripts. These work for me. They may not work for you.

I am running unslung V4.0 All these diversion scripts sit in /unslung along with md.o, raid1.o mdadm, and mdadm.conf.

 
# We edit rc to prevent premature mounting of the drive which may unsync the raid.
# cat rc
## Simple beta script to verify csr

#/usr/bin/Set_Led r_blinking &
mount -t proc proc /proc
mount -t usbdevfs usbdevfs /proc/bus/usb
mount -o remount,rw /dev/root /

if [ -f /.ramdisk ] ; then
   echo "Root filesystem is running in maintenance mode ..."
   ( cd /home/httpd/html/Management ; mv upgrade-maint.htm upgrade.htm )
fi

#if ( [ -f /.sda2root ] || [ -f /.sdb2root ] ) ; then
#   echo "Root filesystem is running a external disk ..."
#   ( cd /home/httpd/html/Management ; mv upgrade-maint.htm upgrade.htm )
#fi

# Wait for the USB disks to be recognised.
sleep 5

sed -n -e '/^#/p' < /etc/fstab > /etc/mtab

if ( [ -f /proc/hd_conn ] ) ; then
# Do not mount - Will de-sync Raid.
#  /bin/mount -t ext3 /dev/sda2 /share/hdd/conf
  /bin/rm -rf /mnt/sda2 ; /bin/ln -s /share/hdd/conf /mnt/sda2
fi

ifconfig lo 127.0.0.1
route add -net 127.0.0.0 netmask 255.255.255.0 lo
/bin/echo "Insmod ixp400"
insmod ixp400.o
/bin/echo "Insmod ixp425"
insmod ixp425_eth.o

# /bin/inetd &
# dhcpcd ixp0 -h `hostname` &
/etc/rc.d/rc.sysinit &

return 0
#  
 
  1. cat rc.sysinit

The original rc.sysinit is called after loading the drivers and starting the raid arrays. I am raiding swap, /share/hdd/conf, and /share/hdd/data. Getting the raid built is a bit tricky. Be sure to read the LDP article.

 
#!/bin/sh

/bin/umount /dev/sda1
/bin/umount /dev/sda2
/bin/umount /dev/sdb1
/bin/umount /dev/sdb2
mknod /dev/md0 b 9 0
mknod /dev/md1 b 9 1
mknod /dev/md2 b 9 2
mknod /dev/md3 b 9 3
/sbin/insmod /unslung/md.o
/sbin/insmod /unslung/raid1.o
[ -f /etc/mdadm.conf ] || cp /unslung/mdadm.conf /etc
[ -f /sbin/mdadm ] || cp /unslung/mdadm /sbin
/sbin/mdadm -As
sleep 5
#Start In this order to see if this will affect reconstruction order
/sbin/swapon /dev/md3
/bin/mount /dev/md2 /share/hdd/conf
/bin/mount /dev/md1 /share/hdd/data
return 1

 


 
rc.1 must provide equivalents for rc.bootbin.
These are ifup and swapon.
We don't need to ifconfig, necause switchbox already started ot in 4.x.
We don't need swapon, because we already started swap.
We disable ( comment out ) stuff that will cause problems.
# cat rc.1

#!/bin/sh

if ( [ -f /proc/hd2_conn ] ) ; then
  /bin/umount /dev/sdb2
fi

#/sbin/ifconfig ixp0 hw ether 00:C0:02:01:01:04
#/bin/echo  "Starting Set CGI_ds.conf:"; /etc/rc.d/rc.bootbin; check_status
/sbin/ifup
/sbin/swapon -a

cp /opt/etc/passwd /etc/passwd
cp /opt/etc/passwd /share/hdd/conf/passwd
[ -L /root ] || ln -sf /opt/root /root

/bin/echo  "Restore time and timezone:"; /etc/rc.d/rc.rstimezone; check_status
#/bin/echo  "Restore usrgrpshares:"; /etc/rc.d/rc.reset_usrgrpshare; check_statu
s
#/bin/echo  "Generating telnet password:"; /usr/sbin/TelnetPassword; check_statu
s
/bin/echo  "Starting WEB Server:"; . /etc/rc.d/rc.thttpd;check_status
/bin/echo  "Starting samba:"; . /etc/rc.d/rc.samba
#/bin/echo  "Starting download:"; /usr/sbin/download
#/bin/echo  "Starting INET Server:"; . /etc/rc.d/rc.xinetd; check_status
/bin/echo  "Creating ramfs for /tmp:"; mount -t ramfs none /tmp -o maxsize=512
chmod 777 /tmp
#/bin/echo  "Starting QuickSet Daemon :"; . /etc/rc.d/rc.quickset
/bin/echo  "Starting Crond :"; . /etc/rc.d/rc.crond
/bin/echo  "Starting Rest Task :"; . /etc/rc.d/rc.local

/bin/echo  "Starting UNSLUNG Packages:"; ( . /etc/rc.d/rc.unslung-start )

/usr/bin/Set_Led ready
/usr/bin/Set_Led beep1
#/bin/echo  "Checking disk status :"; /usr/sbin/CheckDiskFull 2 >/dev/null

return 0

#
 
view · edit · print · history · Last edited by glc.
Originally by glc.
Page last modified on April 14, 2005, at 10:26 PM