1.\" $OpenBSD: softraid.4,v 1.29 2012/01/02 08:24:44 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: January 2 2012 $ 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.It CONCAT 105A 106.Em concatenating 107discipline. 108It writes data to each chunk in sequence to provide increased capacity. 109CONCAT does not provide redundancy. 110.El 111.Sh EXAMPLES 112An example to create a 3 chunk RAID 1 from scratch is as follows: 113.Pp 114Initialize the partition tables of all disks: 115.Bd -literal -offset indent 116# fdisk -iy wd1 117# fdisk -iy wd2 118# fdisk -iy wd3 119.Ed 120.Pp 121Now create RAID partitions on all disks: 122.Bd -literal -offset indent 123# printf "a\en\en\en\enRAID\enw\enq\en\en" | disklabel -E wd1 124# printf "a\en\en\en\enRAID\enw\enq\en\en" | disklabel -E wd2 125# printf "a\en\en\en\enRAID\enw\enq\en\en" | disklabel -E wd3 126.Ed 127.Pp 128Assemble the RAID volume: 129.Bd -literal -offset indent 130# bioctl -c 1 -l /dev/wd1a,/dev/wd2a,/dev/wd3a softraid0 131.Ed 132.Pp 133The console will show what device was added to the system: 134.Bd -literal -offset indent 135scsibus0 at softraid0: 1 targets 136sd0 at scsibus0 targ 0 lun 0: \*(LtOPENBSD, SR RAID 1, 001\*(Gt SCSI2 137sd0: 1MB, 0 cyl, 255 head, 63 sec, 512 bytes/sec, 3714 sec total 138.Ed 139.Pp 140It is good practice to wipe the front of the disk before using it: 141.Bd -literal -offset indent 142# dd if=/dev/zero of=/dev/rsd0c bs=1m count=1 143.Ed 144.Pp 145Initialize the partition table and create a filesystem on the 146new RAID volume: 147.Bd -literal -offset indent 148# fdisk -iy sd0 149# printf "a\en\en\en\en4.2BSD\enw\enq\en\en" | disklabel -E sd0 150# newfs /dev/rsd0a 151.Ed 152.Pp 153The RAID volume is now ready to be used as a normal disk device. 154See 155.Xr bioctl 8 156for more information on configuration of RAID sets. 157.Sh SEE ALSO 158.Xr bio 4 , 159.Xr bioctl 8 , 160.Xr disklabel 8 , 161.Xr fdisk 8 , 162.Xr newfs 8 163.Sh HISTORY 164The 165.Nm 166driver first appeared in 167.Ox 4.2 . 168.Sh AUTHORS 169.An Marco Peereboom . 170.Sh CAVEATS 171The driver relies on underlying hardware to properly fail chunks. 172.Pp 173The RAID 1 discipline does not initialize the mirror upon creation. 174This is by design because all sectors that are read are written first. 175There is no point in wasting a lot of time syncing random data. 176.Pp 177The RAID 4 and 5 disciplines do not initialize the parity upon creation. 178This is due to the scrub functionality not being currently implemented. 179.Pp 180Currently there is no automated mechanism to recover from failed disks. 181.Pp 182There is no boot support at this time for any disciplines. 183.Pp 184Sparc hardware needs to use fstype 185.Dq 4.2BSD 186instead of 187.Dq RAID . 188.Pp 189Certain RAID levels can protect against some data loss 190due to component failure. 191RAID is 192.Em not 193a substitute for good backup practices. 194