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