1.\" $OpenBSD: softraid.4,v 1.25 2009/10/11 14:29:49 sobrado 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: October 11 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 60is used to alter the fstype. 61.Pp 62Currently 63.Nm 64supports the following disciplines: 65.Bl -ohang -offset indent 66.It RAID 0 67A 68.Em striping 69discipline. 70It segments data over a number of chunks to increase performance. 71RAID 0 does not provide for data loss (redundancy). 72.It RAID 1 73A 74.Em mirroring 75discipline. 76It copies data across more than one chunk to provide for data loss. 77Read performance is increased, 78though at the cost of write speed. 79Unlike traditional RAID 1, 80.Nm 81supports the use of more than two chunks in a RAID 1 setup. 82.It RAID 4 83A striping discipline with a 84.Em fixed parity 85chunk. 86It stripes data across chunks and provides parity to prevent data loss of 87a single chunk failure. 88Read performance is increased, 89though write performance is limited by the parity chunk. 90.It RAID 5 91A striping discipline with 92.Em floating parity 93across all chunks. 94It stripes data across chunks and provides parity to prevent data loss of 95a single chunk failure. 96Read performance is increased; 97write performance should be faster than RAID 4. 98.It CRYPTO 99An 100.Em encrypting 101discipline. 102It encrypts data on a single chunk to provide for data confidentiality. 103CRYPTO does not provide redundancy. 104.El 105.Sh EXAMPLES 106An example to create a 3 chunk RAID 1 from scratch is as follows: 107.Pp 108Initialize the partition tables of all disks: 109.Bd -literal -offset indent 110# fdisk -iy wd1 111# fdisk -iy wd2 112# fdisk -iy wd3 113.Ed 114.Pp 115Now create RAID partitions on all disks: 116.Bd -literal -offset indent 117# printf "a\en\en\en\enRAID\enw\enq\en\en" | disklabel -E wd1 118# printf "a\en\en\en\enRAID\enw\enq\en\en" | disklabel -E wd2 119# printf "a\en\en\en\enRAID\enw\enq\en\en" | disklabel -E wd3 120.Ed 121.Pp 122Assemble the RAID volume: 123.Bd -literal -offset indent 124# bioctl -c 1 -l /dev/wd1a,/dev/wd2a,/dev/wd3a softraid0 125.Ed 126.Pp 127The console will show what device was added to the system: 128.Bd -literal -offset indent 129scsibus0 at softraid0: 1 targets 130sd0 at scsibus0 targ 0 lun 0: \*(LtOPENBSD, SR RAID 1, 001\*(Gt SCSI2 131sd0: 1MB, 0 cyl, 255 head, 63 sec, 512 bytes/sec, 3714 sec total 132.Ed 133.Pp 134It is good practice to wipe the front of the disk before using it: 135.Bd -literal -offset indent 136# dd if=/dev/zero of=/dev/rsd0c bs=1m count=1 137.Ed 138.Pp 139Initialize the partition table and create a filesystem on the 140new RAID volume: 141.Bd -literal -offset indent 142# fdisk -iy sd0 143# printf "a\en\en\en\en4.2BSD\enw\enq\en\en" | disklabel -E sd0 144# newfs /dev/rsd0a 145.Ed 146.Pp 147The RAID volume is now ready to be used as a normal disk device. 148See 149.Xr bioctl 8 150for more information on configuration of RAID sets. 151.Sh SEE ALSO 152.Xr bio 4 , 153.Xr bioctl 8 , 154.Xr disklabel 8 , 155.Xr fdisk 8 , 156.Xr newfs 8 157.Sh HISTORY 158The 159.Nm 160driver first appeared in 161.Ox 4.2 . 162.Sh AUTHORS 163.An Marco Peereboom . 164.Sh CAVEATS 165The driver relies on underlying hardware to properly fail chunks. 166Currently RAID 1 support does not have the ability to recover a 167failed chunk. 168.Pp 169The RAID 1 discipline does not initialize the mirror upon creation. 170This is by design because all sectors that are read are written first. 171There is no point in wasting a lot of time syncing random data. 172.Pp 173The RAID 4 and 5 disciplines do not initialize the parity upon creation. 174This is due to the scrub functionality not being currently implemented. 175.Pp 176Currently there is no automated mechanism to recover from failed disks. 177.Pp 178There is no boot support at this time for any disciplines. 179.Pp 180Sparc hardware needs to use fstype 181.Dq 4.2BSD 182instead of 183.Dq RAID . 184.Pp 185Certain RAID levels can protect against some data loss 186due to component failure. 187RAID is 188.Em not 189a substitute for good backup practices. 190