# Software RAID with FreeBSD



## shmget (Jul 6, 2009)

I am considering installing FreeBSD in a system that will have two hard drives (of similar size).  I'm curious as to the state of software RAID in FreeBSD 7.2.  Can anyone comment on their experiences with it?

When a disk finally stops working properly, how is a sysadmin alerted to this?  Does the kernel generate a message in /var/log/messages?


----------



## phoenix (Jul 6, 2009)

gmirror(8) works very nicely, and is fairly easy to configure.  There are notes about it in the handbook, and how-tos posted at freebsd.org (although I believe you still need to do a web search for them).

zfs(8) also supports mirroring, and works very nicely as well.  You can't (yet) boot off a zfs setup using any FreeBSD RELEASE, but support for that should be available in 7.3 and 8.0 once they are released.

Messages are logged, and one can query for the status of the mirror.  I use a little shell script that queries the status of my gmirror and zpool and sends an e-mail if there are problems.  This is run via crontab every 15 minutes.


```
#!/bin/sh

send=0

email="someaddress@someplace.com"

# Check zpool status
status=$( zpool status -x )

if [ "${status}" != "all pools are healthy" ]; then
        zpoolmsg="Problems with ZFS: ${status}"
        send=1
fi

# Check gmirror status
status=$(gmirror status)

if $( gmirror status | grep DEGRADED > /dev/null ); then
        gmirrormsg="Problems with gmirror: ${status}"
        send=1
fi

# Send status e-mail if needed
if [ "${send}" -eq 1 ]; then
        echo "${zpoolmsg} ${gmirrormsg}" | mail -s "Filesystem Issues on TheHive" ${email}
fi

exit 0
```


----------

