xref: /freebsd/sbin/ccdconfig/ccdconfig.8 (revision 90aad5d3e44d137ce80d2ec257de07c7c1367bd3)
1.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to The NetBSD Foundation
5.\" by Jason R. Thorpe.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\" $NetBSD: ccdconfig.8,v 1.4 1996/02/28 01:01:17 thorpej Exp $
29.\"
30.Dd March 17, 2022
31.Dt CCDCONFIG 8
32.Os
33.Sh NAME
34.Nm ccdconfig
35.Nd configuration utility for the concatenated disk driver
36.Sh SYNOPSIS
37.Nm
38.Op Fl cv
39.Ar ccd
40.Ar ileave
41.Op Ar flags
42.Ar dev ...
43.Nm
44.Fl C
45.Op Fl v
46.Op Fl f Ar config_file
47.Nm
48.Fl u
49.Op Fl v
50.Ar ccd ...
51.Nm
52.Fl U
53.Op Fl v
54.Op Fl f Ar config_file
55.Nm
56.Fl g
57.Op Ar ccd ...
58.Sh DESCRIPTION
59The
60.Nm
61utility is used to dynamically configure and unconfigure concatenated disk
62devices, or ccds.
63For more information about the ccd, see
64.Xr ccd 4 .
65.Pp
66The options are as follows:
67.Bl -tag -width indent
68.It Fl c
69Configure a ccd.
70This is the default behavior of
71.Nm .
72.It Fl C
73Configure all ccd devices listed in the ccd configuration file.
74.It Fl f Ar config_file
75When configuring or unconfiguring all devices, read the file
76.Pa config_file
77instead of the default
78.Pa /etc/ccd.conf .
79.It Fl g
80Dump the current ccd configuration in a format suitable for use as the
81ccd configuration file.
82If no arguments are specified, every configured
83ccd is dumped.
84Otherwise, the configuration of each listed ccd is dumped.
85.It Fl u
86Unconfigure a ccd.
87.It Fl U
88Unconfigure all ccd devices listed the ccd configuration file.
89.It Fl v
90Cause
91.Nm
92to be verbose.
93.El
94.Pp
95A ccd is described on the command line and in the ccd configuration
96file by the name of the ccd, the interleave factor, the ccd configuration
97flags, and a list of one or more devices.
98The flags may be represented
99as a decimal number, a hexadecimal number, a comma-separated list
100of strings, or the word
101.Dq none .
102The flags are as follows:
103.Bd -literal -offset indent
104CCDF_UNIFORM	0x02		Use uniform interleave
105CCDF_MIRROR	0x04		Support mirroring
106CCDF_NO_OFFSET	0x08		Do not use an offset
107CCDF_LINUX	0x0A		Linux md(4) compatibility
108.Ed
109.Pp
110The format in the
111configuration file appears exactly as if it were entered on the command line.
112Note that on the command line and in the configuration file, the
113.Pa flags
114argument is optional.
115.Bd -literal -offset indent
116#
117# /etc/ccd.conf
118# Configuration file for concatenated disk devices
119#
120
121# ccd           ileave  flags   component devices
122ccd0            16      none    /dev/da2s1 /dev/da3s1
123.Ed
124.Pp
125The component devices need to name partitions of type
126.Li FS_BSDFFS
127(or
128.Dq 4.2BSD
129as shown by
130.Xr disklabel 8 ) .
131.Pp
132If you want to use the
133.Tn Linux
134.Xr md 4
135compatibility mode, please be sure
136to read the notes in
137.Xr ccd 4 .
138.Sh FILES
139.Bl -tag -width /etc/ccd.conf -compact
140.It Pa /etc/ccd.conf
141default ccd configuration file
142.El
143.Sh EXAMPLES
144A number of
145.Nm
146examples are shown below.
147The arguments passed
148to
149.Nm
150are exactly the same as you might place in the
151.Pa /etc/ccd.conf
152configuration file.
153The first example creates a 4-disk stripe out of
154four scsi disk partitions.
155The stripe uses a 64 sector interleave.
156The second example is an example of a complex stripe/mirror combination.
157It reads as a two disk stripe of da4 and da5 which is mirrored
158to a two disk stripe of da6 and da7.
159The last example is a simple
160mirror.
161The second slice of /dev/da8 is mirrored with the third slice of /dev/da9
162and assigned to ccd0.
163.Bd -literal
164# ccdconfig ccd0 64 none /dev/da0s1 /dev/da1s1 /dev/da2s1 /dev/da3s1
165# ccdconfig ccd0 128 CCDF_MIRROR /dev/da4 /dev/da5 /dev/da6 /dev/da7
166# ccdconfig ccd0 128 CCDF_MIRROR /dev/da8s2 /dev/da9s3
167.Ed
168.Pp
169The following are matching commands in
170.Tn Linux
171and
172.Fx
173to create a RAID-0 in
174.Tn Linux
175and read it from
176.Fx .
177.Bd -literal
178# Create a RAID-0 on Linux:
179mdadm --create --chunk=32 --level=0 --raid-devices=2 /dev/md0 \\
180   /dev/hda1 /dev/hdb1
181# Make the RAID-0 just created available on FreeBSD:
182ccdconfig -c /dev/ccd0 32 linux /dev/ada0s1 /dev/ada0s2
183.Ed
184.Pp
185When you create a new ccd disk you generally want to
186.Xr fdisk 8
187and
188.Xr disklabel 8
189it before doing anything else.
190Once you create the initial label you can
191edit it, adding additional partitions.
192The label itself takes up the first
19316 sectors of the ccd disk.
194If all you are doing is creating file systems
195with newfs, you do not have to worry about this as newfs will skip the
196label area.
197However, if you intend to
198.Xr dd 1
199to or from a ccd partition it is usually a good idea to construct the
200partition such that it does not overlap the label area.
201For example, if
202you have A ccd disk with 10000 sectors you might create a 'd' partition
203with offset 16 and size 9984.
204.Bd -literal
205# disklabel ccd0 > /tmp/disklabel.ccd0
206# disklabel -R ccd0 /tmp/disklabel.ccd0
207# disklabel -e ccd0
208.Ed
209.Pp
210The disklabeling of a ccd disk is usually a one-time affair.
211If you reboot the machine and reconfigure the ccd disk,
212the disklabel you
213had created before will still be there and not require reinitialization.
214Beware that changing any ccd parameters: interleave, flags, or the
215device list making up the ccd disk, will usually destroy any prior
216data on that ccd disk.
217If this occurs it is usually a good idea to
218reinitialize the label before [re]constructing your ccd disk.
219.Sh RECOVERY
220An error on a ccd disk is usually unrecoverable unless you are using the
221mirroring option.
222But mirroring has its own perils: It assumes that
223both copies of the data at any given sector are the same.
224This holds true
225until a write error occurs or until you replace either side of the mirror.
226This is a poor-man's mirroring implementation.
227It works well enough that if
228you begin to get disk errors you should be able to backup the ccd disk,
229replace the broken hardware, and then regenerate the ccd disk.
230If you need
231more than this you should look into external hardware RAID SCSI boxes,
232RAID controllers (see GENERIC),
233or software RAID systems such as
234.Xr geom 8
235and
236.Xr gvinum 8 .
237.Sh SEE ALSO
238.Xr dd 1 ,
239.Xr ccd 4 ,
240.Xr disklabel 8 ,
241.Xr fdisk 8 ,
242.Xr gvinum 8 ,
243.Xr rc 8
244.Sh HISTORY
245The
246.Nm
247utility first appeared in
248.Nx 1.1 .
249.Sh BUGS
250The initial disklabel returned by
251.Xr ccd 4
252specifies only 3 partitions.
253One needs to change the number of partitions to 8 using
254.Dq Nm disklabel Fl e
255to get the usual
256.Bx
257expectations.
258