1.\" $OpenBSD: softraid.4,v 1.20 2009/04/29 07:02:02 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 $Mdocdate: April 29 2009 $ 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 a Host Bus Adapter (HBA) that provides RAID and other I/O 31related services. 32The 33.Nm 34device provides a scaffold to implement more complex I/O transformation 35disciplines. 36For example, one can tie chunks together into a mirroring discipline. 37There really is no limit on what type of discipline one can write as long 38as it fits the SCSI model. 39.Pp 40.Nm 41supports a number of 42.Em disciplines . 43A discipline is a collection of functions 44that provides specific I/O functionality. 45This includes I/O path, bring-up, failure recovery, and statistical 46information gathering. 47Essentially a discipline is a lower 48level driver that provides the I/O transformation for the softraid 49device. 50.Pp 51A 52.Em volume 53is a virtual disk device that is made up of a collection of chunks. 54.Pp 55A 56.Em chunk 57is a partition or storage area of fstype 58.Dq RAID . 59.Xr disklabel 8 60can be used to alter the fstype, 61though some platforms, 62such as SUN, 63are not capable of using this 64and should use fstype 65.Dq 4.2BSD 66instead. 67.Pp 68Currently 69.Nm 70supports the following disciplines: 71.Bl -ohang -offset indent 72.It RAID 0 73A 74.Em striping 75discipline. 76It segments data over a number of chunks to increase performance. 77RAID 0 does not provide for data loss (redundancy). 78.It RAID 1 79A 80.Em mirroring 81discipline. 82It copies data across more than one chunk to provide for data loss. 83Read performance is increased, 84though at the cost of write speed. 85Unlike traditional RAID 1, 86.Nm 87supports the use of more than two chunks in a RAID 1 setup. 88.It CRYPTO 89An 90.Em encrypting 91discipline. 92It encrypts data on a single chunk to provide for data confidentiality. 93CRYPTO does not provide redundancy. 94.El 95.Sh EXAMPLES 96An example to create a 3 chunk RAID 1 from scratch is as follows: 97.Pp 98Initialize the partition tables of all disks: 99.Bd -literal -offset indent 100# fdisk -iy wd1 101# fdisk -iy wd2 102# fdisk -iy wd3 103.Ed 104.Pp 105Now create RAID partitions on all disks: 106.Bd -literal -offset indent 107# printf "a\en\en\en\enRAID\enw\enq\en\en" | disklabel -E wd1 108# printf "a\en\en\en\enRAID\enw\enq\en\en" | disklabel -E wd2 109# printf "a\en\en\en\enRAID\enw\enq\en\en" | disklabel -E wd3 110.Ed 111.Pp 112Assemble the RAID volume: 113.Bd -literal -offset indent 114# bioctl -c 1 -l /dev/wd1a,/dev/wd2a,/dev/wd3a softraid0 115.Ed 116.Pp 117The console will show what device was added to the system: 118.Bd -literal -offset indent 119scsibus0 at softraid0: 1 targets 120sd0 at scsibus0 targ 0 lun 0: \*(LtOPENBSD, SR RAID 1, 001\*(Gt SCSI2 121sd0: 1MB, 0 cyl, 255 head, 63 sec, 512 bytes/sec, 3714 sec total 122.Ed 123.Pp 124It is good practice to wipe the front of the disk before using it: 125.Bd -literal -offset indent 126# dd if=/dev/zero of=/dev/rsd0c bs=1m count=1 127.Ed 128.Pp 129Initialize the partition table and create a filesystem on the 130new RAID volume: 131.Bd -literal -offset indent 132# fdisk -iy sd0 133# printf "a\en\en\en\en4.2BSD\enw\enq\en\en" | disklabel -E sd0 134# newfs /dev/rsd0a 135.Ed 136.Pp 137The RAID volume is now ready to be used as a normal disk device. 138See 139.Xr bioctl 8 140for more information on configuration of RAID sets. 141.Sh SEE ALSO 142.Xr bioctl 8 , 143.Xr disklabel 8 , 144.Xr fdisk 8 , 145.Xr newfs 8 146.Sh HISTORY 147The 148.Nm 149driver first appeared in 150.Ox 4.2 . 151.Sh AUTHORS 152.An Marco Peereboom . 153.Sh CAVEATS 154The driver relies on underlying hardware to properly fail chunks. 155Currently RAID 1 support does not have the ability to recover a 156failed chunk. 157.Pp 158The RAID 1 discipline does not initialize the mirror upon creation. 159This is by design because all sectors that are read are written first. 160There is no point in wasting a lot of time syncing random data. 161.Pp 162Currently there is no automated mechanism to recover from failed disks. 163.Pp 164There is no boot support at this time for any disciplines. 165.Pp 166Certain RAID levels can protect against some data loss 167due to component failure. 168RAID is 169.Em not 170a substitute for good backup practices. 171