Benno,

On Fri, 07 Jan 2000 13:07:16 +0100, Benno Senoner wrote:

>I was wondering if this procedure (swapping on Raid1 + waiting for the resync),
>is safe on an IDE only system ?

>I don't need hot-swapping, the only thing I need is that if one disk dies,
>swapping will not take down the disk (hangs like in the SCSI case etc).
>
>If this is safe I can easily live with the "wait for resync" issue.

Try this: change "swap" to "raidswap"  in /etc/fstab, then merge this procedure into 
an 
early position in your startup procedures:

>--------------------------------------------------------
#!/bin/sh

FSTAB=/etc/fstab

usage()
{
    echo "usage: $0 start" >&2
    exit 1
}

read_fstab()
{
    awk ' {
        if(NF && substr($1,1,1) != "#" && $3 == "raidswap")
            print $1
    } ' $FSTAB
}

check_raiddev()
{
    raiddev=`basename $1`
    status=`cat /proc/mdstat | awk '
        /^'$raiddev' : / {
            if($NF ~ /\[U*\]/)
                print "OK"
            else
                print "NOK"
        }
    '`
    case "$status" in
        OK)     return 0 ;;
        *)      return 1 ;;
    esac
}


case "$1" in
    start)
        read_fstab | while read device ; do
            if check_raiddev $device ; then
                echo "Start swapping to $device"
                swapon $device
            else
                echo "*** Not swapping to $device: not in sync"
            fi
        done
        ;;
    stop)
        # Just to prevent false usage alarms
        ;;
    *)
        usage
        ;;
esac
>--------------------------------------------------------

Your system will probably give some alarms at startup ("fs type raidswap not in 
kernel" 
or so), but just don't mind.

It's a quick hack (no check for swapping priority et al), but works fine for me.

Regards,
        Robert


Reply via email to