view · edit · print · history

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.

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

# 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 )

#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 )

# 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

ifconfig lo
route add -net netmask 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

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.
# cat rc.sysinit

/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

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

#/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/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
#/bin/echo  "Generating telnet password:"; /usr/sbin/TelnetPassword; check_statu
/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


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


/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/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/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

Here is the mdadm.conf file
# cat mdadm.conf
DEVICE /dev/sd[a-b][1-3]
ARRAY /dev/md3 level=raid1 num-devices=2 
ARRAY /dev/md2 level=raid1 num-devices=2 
ARRAY /dev/md1 level=raid1 num-devices=2 UUID=facbd1db:ece97e6e:e528e756:afa1e2b
view · edit · print · history · Last edited by glc.
Originally by glc.
Page last modified on April 14, 2005, at 10:26 PM