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