1.\" $OpenBSD: softraid.4,v 1.7 2007/04/18 13:38:33 jmc Exp $ 2.\" 3.\" Copyright (c) 2007 Todd T. Fries <todd@OpenBSD.org> 4.\" Copyright (c) 2007 Marco Peereboom <marco@OpenBSD.org> 5.\" 6.\" Permission to use, copy, modify, and distribute this software for any 7.\" purpose with or without fee is hereby granted, provided that the above 8.\" copyright notice and this permission notice appear in all copies. 9.\" 10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" 18.Dd March 19, 2007 19.Dt SOFTRAID 4 20.Os 21.Sh NAME 22.Nm softraid 23.Nd Software RAID 24.Sh SYNOPSIS 25.Cd "softraid0 at root" 26.Cd "scsibus* at softraid?" 27.Sh DESCRIPTION 28The 29.Nm 30device emulates an HBA that provides RAID and other IO related services. 31The idea is to tie chunks together into an IO discipline. 32A discipline can for example provide a volume that mirrors chunks (RAID 1). 33.Pp 34Currently 35.Nm 36only supports a mirroring discipline. 37.Pp 38A 39.Em discipline 40is a collection of functions that provides specific IO 41functionality. 42This includes IO path, bring-up, failure recovery, statistical 43information gathering etc.\& 44Essentially a discipline is a lower 45level driver that provides the IO transformation for the softraid 46device. 47.Pp 48A 49.Em volume 50is a virtual disk device that is made up of a collection of chunks. 51.Pp 52A 53.Em chunk 54is a partition or storage area of the type RAID. 55.Sh EXAMPLES 56The first step to using the 57.Nm 58driver is to ensure that it is suitably configured in the kernel. 59This is done by uncommenting the softraid device in sys/conf/GENERIC and 60recompiling it. 61Uncomment the folowing lines: 62.Bd -literal -offset indent 63#softraid0 at root # Software RAID 64#scsibus* at softraid? 65.Ed 66.Pp 67An example to create a 3 chunk RAID 1 from scratch is as follows: 68.Pp 69Initialize the partition tables of all disks: 70.Bd -literal -offset indent 71echo y | fdisk -i wd1 72echo y | fdisk -i wd2 73echo y | fdisk -i wd3 74.Ed 75.Pp 76Now create RAID partitions on all disks: 77.Bd -literal -offset indent 78echo "d a\ena\en\en\en\enRAID\enw\enq\en" | disklabel -E wd1 79echo "d a\ena\en\en\en\enRAID\enw\enq\en" | disklabel -E wd2 80echo "d a\ena\en\en\en\enRAID\enw\enq\en" | disklabel -E wd3 81.Ed 82.Pp 83Assemble the RAID volume: 84.Bd -literal -offset indent 85bioctl -c 1 -l /dev/wd1a,/dev/wd2a,/dev/wd3a softraid0 86.Ed 87.Pp 88The console will give away what device was added to the system: 89.Bd -literal -offset indent 90scsibus0 at softraid0: 1 targets 91sd0 at scsibus0 targ 0 lun 0: <OPENBSD, SR RAID 1, 001> SCSI2 92sd0: 1MB, 0 cyl, 255 head, 63 sec, 512 bytes/sec, 3714 sec total 93.Ed 94.Pp 95It is good practice to wipe the front of the disk before using it: 96.Bd -literal -offset indent 97dd if=/dev/zero of=/dev/rsd0c bs=1m count=1 98.Ed 99.Pp 100Initialize the partition table and create a filesystem on the 101new RAID volume: 102.Bd -literal -offset indent 103echo y | fdisk -i sd0 104echo "d a\ena\en\en\en\en4.2BSD\enw\enq\en" | disklabel -E sd0 105newfs /dev/rsd0a 106.Ed 107.Pp 108The RAID volume is now ready to be used as a normal disk device. 109.Pp 110See 111.Xr bioctl 8 112for more information on configuration of RAID sets. 113.Pp 114All component partitions must be of type 115.Dv RAID . 116Some platforms, such as SUN, are not capable of using the 117.Dv RAID 118partition type. 119The 120.Dv 4.2BSD 121partition type should be used on such platforms. 122.Sh SEE ALSO 123.Xr sd 4 , 124.Xr wd 4 , 125.Xr bioctl 8 , 126.Xr config 8 , 127.Xr fsck 8 , 128.Xr MAKEDEV 8 , 129.Xr mount 8 , 130.Xr newfs 8 131.Sh HISTORY 132The 133.Nm 134driver 135is an original work by Marco Peereboom. 136It first appeared in 137.Ox 4.2 . 138.Sh CAVEATS 139The driver relies on underlying hardware to properly fail chunks. 140Currently the RAID 1 support does not have the ability to recover a 141failed chunk. 142.Pp 143The RAID 1 discipline does not initialize the mirror upon creation. 144.Pp 145Certain RAID levels can protect against some data loss 146due to component failure. 147RAID is 148.Em not 149a substitute for good backup practices. 150