1.\" $OpenBSD: softraid.4,v 1.36 2014/02/08 17:05:15 chris 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: February 8 2014 $ 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.Sh DESCRIPTION 27The 28.Nm 29device emulates a Host Bus Adapter (HBA) that provides RAID and other I/O 30related services. 31The 32.Nm 33device provides a scaffold to implement more complex I/O transformation 34disciplines. 35For example, one can tie chunks together into a mirroring discipline. 36There really is no limit on what type of discipline one can write as long 37as it fits the SCSI model. 38.Pp 39.Nm 40supports a number of 41.Em disciplines . 42A discipline is a collection of functions 43that provides specific I/O functionality. 44This includes I/O path, bring-up, failure recovery, and statistical 45information gathering. 46Essentially a discipline is a lower 47level driver that provides the I/O transformation for the softraid 48device. 49.Pp 50A 51.Em volume 52is a virtual disk device that is made up of a collection of chunks. 53.Pp 54A 55.Em chunk 56is a partition or storage area of fstype 57.Dq RAID . 58.Xr disklabel 8 59is used to alter the fstype. 60.Pp 61Currently 62.Nm 63supports the following disciplines: 64.Bl -ohang -offset indent 65.It RAID 0 66A 67.Em striping 68discipline. 69It segments data over a number of chunks to increase performance. 70RAID 0 does not provide for data loss (redundancy). 71.It RAID 1 72A 73.Em mirroring 74discipline. 75It copies data across more than one chunk to provide for data loss. 76Read performance is increased, 77though at the cost of write speed. 78Unlike traditional RAID 1, 79.Nm 80supports the use of more than two chunks in a RAID 1 setup. 81.\" .It RAID 5 82.\" A striping discipline with 83.\" .Em floating parity 84.\" across all chunks. 85.\" It stripes data across chunks and provides parity to prevent data loss of 86.\" a single chunk failure. 87.\" Read performance is increased; 88.\" write performance does incur additional overhead. 89.It CRYPTO 90An 91.Em encrypting 92discipline. 93It encrypts data on a single chunk to provide for data confidentiality. 94CRYPTO does not provide redundancy. 95.It CONCAT 96A 97.Em concatenating 98discipline. 99It writes data to each chunk in sequence to provide increased capacity. 100CONCAT does not provide redundancy. 101.El 102.Pp 103.Xr installboot 8 104may be used to install 105.Xr boot 8 106in the boot storage area of the 107.Nm 108volume. 109Boot support is currently limited to the CRYPTO and RAID 1 disciplines 110on amd64 and i386 platforms. 111At the 112.Xr boot 8 113prompt, softraid volumes have names beginning with 114.Sq sr 115and can be booted from like a normal disk device. 116CRYPTO volumes will require a decryption passphrase or keydisk at boot time. 117.Sh EXAMPLES 118An example to create a 3 chunk RAID 1 from scratch is as follows: 119.Pp 120Initialize the partition tables of all disks: 121.Bd -literal -offset indent 122# fdisk -iy wd1 123# fdisk -iy wd2 124# fdisk -iy wd3 125.Ed 126.Pp 127Now create RAID partitions on all disks: 128.Bd -literal -offset indent 129# printf "a\en\en\en\enRAID\enw\enq\en\en" | disklabel -E wd1 130# printf "a\en\en\en\enRAID\enw\enq\en\en" | disklabel -E wd2 131# printf "a\en\en\en\enRAID\enw\enq\en\en" | disklabel -E wd3 132.Ed 133.Pp 134Assemble the RAID volume: 135.Bd -literal -offset indent 136# bioctl -c 1 -l /dev/wd1a,/dev/wd2a,/dev/wd3a softraid0 137.Ed 138.Pp 139The console will show what device was added to the system: 140.Bd -literal -offset indent 141scsibus0 at softraid0: 1 targets 142sd0 at scsibus0 targ 0 lun 0: \*(LtOPENBSD, SR RAID 1, 001\*(Gt SCSI2 143sd0: 1MB, 0 cyl, 255 head, 63 sec, 512 bytes/sec, 3714 sec total 144.Ed 145.Pp 146It is good practice to wipe the front of the disk before using it: 147.Bd -literal -offset indent 148# dd if=/dev/zero of=/dev/rsd0c bs=1m count=1 149.Ed 150.Pp 151Initialize the partition table and create a filesystem on the 152new RAID volume: 153.Bd -literal -offset indent 154# fdisk -iy sd0 155# printf "a\en\en\en\en4.2BSD\enw\enq\en\en" | disklabel -E sd0 156# newfs /dev/rsd0a 157.Ed 158.Pp 159The RAID volume is now ready to be used as a normal disk device. 160See 161.Xr bioctl 8 162for more information on configuration of RAID sets. 163.Pp 164Install 165.Xr boot 8 166on the RAID volume: 167.Bd -literal -offset indent 168# installboot sd0 169.Ed 170.Pp 171At the 172.Xr boot 8 173prompt, load the /bsd kernel from the RAID volume: 174.Bd -literal -offset indent 175boot> boot sr0a:/bsd 176.Ed 177.Sh SEE ALSO 178.Xr bio 4 , 179.Xr bioctl 8 , 180.Xr disklabel 8 , 181.Xr fdisk 8 , 182.Xr installboot 8 , 183.Xr newfs 8 184.Sh HISTORY 185The 186.Nm 187driver first appeared in 188.Ox 4.2 . 189.Sh AUTHORS 190.An Marco Peereboom . 191.Sh CAVEATS 192The driver relies on underlying hardware to properly fail chunks. 193.Pp 194The RAID 1 discipline does not initialize the mirror upon creation. 195This is by design because all sectors that are read are written first. 196There is no point in wasting a lot of time syncing random data. 197.Pp 198.\" The RAID 5 discipline do not initialize the parity upon creation. 199.\" This is due to the scrub functionality not being currently implemented. 200.\" .Pp 201Currently there is no automated mechanism to recover from failed disks. 202.Pp 203Sparc hardware needs to use fstype 204.Dq 4.2BSD 205instead of 206.Dq RAID . 207.Pp 208Certain RAID levels can protect against some data loss 209due to component failure. 210RAID is 211.Em not 212a substitute for good backup practices. 213