xref: /freebsd/sbin/ccdconfig/ccdconfig.8 (revision c407d351df08a226f81f5de4406f7371aa6ed270)
13a7c4a1cSPedro F. Giffuni.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
289a7b2b7SSatoshi Asami.\" All rights reserved.
389a7b2b7SSatoshi Asami.\"
43a7c4a1cSPedro F. Giffuni.\" This code is derived from software contributed to The NetBSD Foundation
53a7c4a1cSPedro F. Giffuni.\" by Jason R. Thorpe.
63a7c4a1cSPedro F. Giffuni.\"
789a7b2b7SSatoshi Asami.\" Redistribution and use in source and binary forms, with or without
889a7b2b7SSatoshi Asami.\" modification, are permitted provided that the following conditions
989a7b2b7SSatoshi Asami.\" are met:
1089a7b2b7SSatoshi Asami.\" 1. Redistributions of source code must retain the above copyright
1189a7b2b7SSatoshi Asami.\"    notice, this list of conditions and the following disclaimer.
1289a7b2b7SSatoshi Asami.\" 2. Redistributions in binary form must reproduce the above copyright
1389a7b2b7SSatoshi Asami.\"    notice, this list of conditions and the following disclaimer in the
1489a7b2b7SSatoshi Asami.\"    documentation and/or other materials provided with the distribution.
1589a7b2b7SSatoshi Asami.\"
1689a7b2b7SSatoshi Asami.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1789a7b2b7SSatoshi Asami.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1889a7b2b7SSatoshi Asami.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1989a7b2b7SSatoshi Asami.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2089a7b2b7SSatoshi Asami.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
2189a7b2b7SSatoshi Asami.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2289a7b2b7SSatoshi Asami.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2389a7b2b7SSatoshi Asami.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2489a7b2b7SSatoshi Asami.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2589a7b2b7SSatoshi Asami.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2689a7b2b7SSatoshi Asami.\" SUCH DAMAGE.
2789a7b2b7SSatoshi Asami.\"
2802547822SPedro F. Giffuni.\" $NetBSD: ccdconfig.8,v 1.4 1996/02/28 01:01:17 thorpej Exp $
299ad54eb7SPhilippe Charnier.\"
30a3ed434aSEd Maste.Dd January 24, 2024
3189a7b2b7SSatoshi Asami.Dt CCDCONFIG 8
329fe48c6eSRuslan Ermilov.Os
3389a7b2b7SSatoshi Asami.Sh NAME
3489a7b2b7SSatoshi Asami.Nm ccdconfig
3589a7b2b7SSatoshi Asami.Nd configuration utility for the concatenated disk driver
3689a7b2b7SSatoshi Asami.Sh SYNOPSIS
377c7fb079SRuslan Ermilov.Nm
3889a7b2b7SSatoshi Asami.Op Fl cv
3989a7b2b7SSatoshi Asami.Ar ccd
4089a7b2b7SSatoshi Asami.Ar ileave
4189a7b2b7SSatoshi Asami.Op Ar flags
428d646af5SRuslan Ermilov.Ar dev ...
437c7fb079SRuslan Ermilov.Nm
4489a7b2b7SSatoshi Asami.Fl C
4589a7b2b7SSatoshi Asami.Op Fl v
4689a7b2b7SSatoshi Asami.Op Fl f Ar config_file
477c7fb079SRuslan Ermilov.Nm
4889a7b2b7SSatoshi Asami.Fl u
4989a7b2b7SSatoshi Asami.Op Fl v
508d646af5SRuslan Ermilov.Ar ccd ...
517c7fb079SRuslan Ermilov.Nm
5289a7b2b7SSatoshi Asami.Fl U
5389a7b2b7SSatoshi Asami.Op Fl v
5489a7b2b7SSatoshi Asami.Op Fl f Ar config_file
557c7fb079SRuslan Ermilov.Nm
5689a7b2b7SSatoshi Asami.Fl g
578d646af5SRuslan Ermilov.Op Ar ccd ...
5889a7b2b7SSatoshi Asami.Sh DESCRIPTION
59e1205e80SPhilippe CharnierThe
60e1205e80SPhilippe Charnier.Nm
61e1205e80SPhilippe Charnierutility is used to dynamically configure and unconfigure concatenated disk
629806e231SRuslan Ermilovdevices, or ccds.
639806e231SRuslan ErmilovFor more information about the ccd, see
6489a7b2b7SSatoshi Asami.Xr ccd 4 .
6589a7b2b7SSatoshi Asami.Pp
6689a7b2b7SSatoshi AsamiThe options are as follows:
6789a7b2b7SSatoshi Asami.Bl -tag -width indent
6889a7b2b7SSatoshi Asami.It Fl c
699806e231SRuslan ErmilovConfigure a ccd.
709806e231SRuslan ErmilovThis is the default behavior of
717c7fb079SRuslan Ermilov.Nm .
7289a7b2b7SSatoshi Asami.It Fl C
7389a7b2b7SSatoshi AsamiConfigure all ccd devices listed in the ccd configuration file.
7489a7b2b7SSatoshi Asami.It Fl f Ar config_file
7589a7b2b7SSatoshi AsamiWhen configuring or unconfiguring all devices, read the file
7689a7b2b7SSatoshi Asami.Pa config_file
7789a7b2b7SSatoshi Asamiinstead of the default
7889a7b2b7SSatoshi Asami.Pa /etc/ccd.conf .
7989a7b2b7SSatoshi Asami.It Fl g
8089a7b2b7SSatoshi AsamiDump the current ccd configuration in a format suitable for use as the
819806e231SRuslan Ermilovccd configuration file.
829806e231SRuslan ErmilovIf no arguments are specified, every configured
839806e231SRuslan Ermilovccd is dumped.
849806e231SRuslan ErmilovOtherwise, the configuration of each listed ccd is dumped.
8589a7b2b7SSatoshi Asami.It Fl u
8689a7b2b7SSatoshi AsamiUnconfigure a ccd.
8789a7b2b7SSatoshi Asami.It Fl U
8889a7b2b7SSatoshi AsamiUnconfigure all ccd devices listed the ccd configuration file.
8989a7b2b7SSatoshi Asami.It Fl v
909ad54eb7SPhilippe CharnierCause
919ad54eb7SPhilippe Charnier.Nm
9289a7b2b7SSatoshi Asamito be verbose.
9389a7b2b7SSatoshi Asami.El
9489a7b2b7SSatoshi Asami.Pp
9589a7b2b7SSatoshi AsamiA ccd is described on the command line and in the ccd configuration
9689a7b2b7SSatoshi Asamifile by the name of the ccd, the interleave factor, the ccd configuration
979806e231SRuslan Ermilovflags, and a list of one or more devices.
989806e231SRuslan ErmilovThe flags may be represented
9989a7b2b7SSatoshi Asamias a decimal number, a hexadecimal number, a comma-separated list
10089a7b2b7SSatoshi Asamiof strings, or the word
10189a7b2b7SSatoshi Asami.Dq none .
10289a7b2b7SSatoshi AsamiThe flags are as follows:
10305527a9aSRuslan Ermilov.Bd -literal -offset indent
10489a7b2b7SSatoshi AsamiCCDF_UNIFORM	0x02		Use uniform interleave
105cb7c6b53SSatoshi AsamiCCDF_MIRROR	0x04		Support mirroring
1063f4f4a14SMartin CracauerCCDF_NO_OFFSET	0x08		Do not use an offset
1073f4f4a14SMartin CracauerCCDF_LINUX	0x0A		Linux md(4) compatibility
10889a7b2b7SSatoshi Asami.Ed
10989a7b2b7SSatoshi Asami.Pp
11089a7b2b7SSatoshi AsamiThe format in the
11189a7b2b7SSatoshi Asamiconfiguration file appears exactly as if it were entered on the command line.
11289a7b2b7SSatoshi AsamiNote that on the command line and in the configuration file, the
11389a7b2b7SSatoshi Asami.Pa flags
11489a7b2b7SSatoshi Asamiargument is optional.
11505527a9aSRuslan Ermilov.Bd -literal -offset indent
11689a7b2b7SSatoshi Asami#
11789a7b2b7SSatoshi Asami# /etc/ccd.conf
11889a7b2b7SSatoshi Asami# Configuration file for concatenated disk devices
11989a7b2b7SSatoshi Asami#
12005527a9aSRuslan Ermilov
12189a7b2b7SSatoshi Asami# ccd           ileave  flags   component devices
1226d595743SDavid E. O'Brienccd0            16      none    /dev/da2s1 /dev/da3s1
12389a7b2b7SSatoshi Asami.Ed
12489a7b2b7SSatoshi Asami.Pp
125d5bd01d2SRuslan ErmilovIf you want to use the
126d5bd01d2SRuslan Ermilov.Tn Linux
127d5bd01d2SRuslan Ermilov.Xr md 4
128d5bd01d2SRuslan Ermilovcompatibility mode, please be sure
1293f4f4a14SMartin Cracauerto read the notes in
1303f4f4a14SMartin Cracauer.Xr ccd 4 .
1316087df9eSRuslan Ermilov.Sh FILES
1326087df9eSRuslan Ermilov.Bl -tag -width /etc/ccd.conf -compact
1336087df9eSRuslan Ermilov.It Pa /etc/ccd.conf
1346087df9eSRuslan Ermilovdefault ccd configuration file
1356087df9eSRuslan Ermilov.El
136251c176fSRuslan Ermilov.Sh EXAMPLES
137e1205e80SPhilippe CharnierA number of
138e1205e80SPhilippe Charnier.Nm
1399806e231SRuslan Ermilovexamples are shown below.
1409806e231SRuslan ErmilovThe arguments passed
141e1205e80SPhilippe Charnierto
142e1205e80SPhilippe Charnier.Nm
143e1205e80SPhilippe Charnierare exactly the same as you might place in the
14418252fc1SMatthew Dillon.Pa /etc/ccd.conf
1459806e231SRuslan Ermilovconfiguration file.
1469806e231SRuslan ErmilovThe first example creates a 4-disk stripe out of
1479806e231SRuslan Ermilovfour scsi disk partitions.
148*c407d351SYi-Chen LiThe stripe uses a 64-sector interleave.
14918252fc1SMatthew DillonThe second example is an example of a complex stripe/mirror combination.
1506d595743SDavid E. O'BrienIt reads as a two disk stripe of da4 and da5 which is mirrored
1519806e231SRuslan Ermilovto a two disk stripe of da6 and da7.
1529806e231SRuslan ErmilovThe last example is a simple
1539806e231SRuslan Ermilovmirror.
154494b4bb3SSevan JaniyanThe second slice of /dev/da8 is mirrored with the third slice of /dev/da9
1556d595743SDavid E. O'Brienand assigned to ccd0.
15605527a9aSRuslan Ermilov.Bd -literal
1576d595743SDavid E. O'Brien# ccdconfig ccd0 64 none /dev/da0s1 /dev/da1s1 /dev/da2s1 /dev/da3s1
1586d595743SDavid E. O'Brien# ccdconfig ccd0 128 CCDF_MIRROR /dev/da4 /dev/da5 /dev/da6 /dev/da7
1596d595743SDavid E. O'Brien# ccdconfig ccd0 128 CCDF_MIRROR /dev/da8s2 /dev/da9s3
16089a7b2b7SSatoshi Asami.Ed
16189a7b2b7SSatoshi Asami.Pp
162d5bd01d2SRuslan ErmilovThe following are matching commands in
163d5bd01d2SRuslan Ermilov.Tn Linux
164d5bd01d2SRuslan Ermilovand
165d5bd01d2SRuslan Ermilov.Fx
166d5bd01d2SRuslan Ermilovto create a RAID-0 in
167d5bd01d2SRuslan Ermilov.Tn Linux
168d5bd01d2SRuslan Ermilovand read it from
169d5bd01d2SRuslan Ermilov.Fx .
1703f4f4a14SMartin Cracauer.Bd -literal
171d5bd01d2SRuslan Ermilov# Create a RAID-0 on Linux:
1723f4f4a14SMartin Cracauermdadm --create --chunk=32 --level=0 --raid-devices=2 /dev/md0 \\
1733f4f4a14SMartin Cracauer   /dev/hda1 /dev/hdb1
174d5bd01d2SRuslan Ermilov# Make the RAID-0 just created available on FreeBSD:
17505d98029SSergey Kandaurovccdconfig -c /dev/ccd0 32 linux /dev/ada0s1 /dev/ada0s2
1763f4f4a14SMartin Cracauer.Ed
1773f4f4a14SMartin Cracauer.Pp
17818252fc1SMatthew DillonWhen you create a new ccd disk you generally want to
1796d595743SDavid E. O'Brien.Xr fdisk 8
1806d595743SDavid E. O'Brienand
181f6b811beSGiorgos Keramidas.Xr disklabel 8
1829806e231SRuslan Ermilovit before doing anything else.
18318252fc1SMatthew DillonBeware that changing any ccd parameters: interleave, flags, or the
18418252fc1SMatthew Dillondevice list making up the ccd disk, will usually destroy any prior
1859806e231SRuslan Ermilovdata on that ccd disk.
1869806e231SRuslan ErmilovIf this occurs it is usually a good idea to
18718252fc1SMatthew Dillonreinitialize the label before [re]constructing your ccd disk.
18818252fc1SMatthew Dillon.Sh RECOVERY
18918252fc1SMatthew DillonAn error on a ccd disk is usually unrecoverable unless you are using the
1909806e231SRuslan Ermilovmirroring option.
1919806e231SRuslan ErmilovBut mirroring has its own perils: It assumes that
1929806e231SRuslan Ermilovboth copies of the data at any given sector are the same.
1939806e231SRuslan ErmilovThis holds true
19418252fc1SMatthew Dillonuntil a write error occurs or until you replace either side of the mirror.
1959806e231SRuslan ErmilovThis is a poor-man's mirroring implementation.
1969806e231SRuslan ErmilovIt works well enough that if
19718252fc1SMatthew Dillonyou begin to get disk errors you should be able to backup the ccd disk,
1989806e231SRuslan Ermilovreplace the broken hardware, and then regenerate the ccd disk.
1999806e231SRuslan ErmilovIf you need
200b94231daSDima Dorfmanmore than this you should look into external hardware RAID SCSI boxes,
2016d595743SDavid E. O'BrienRAID controllers (see GENERIC),
2026d595743SDavid E. O'Brienor software RAID systems such as
2036d25ea1fSDima Dorfman.Xr geom 8
2046d595743SDavid E. O'Brienand
205d1cd5e7cSJoel Dahl.Xr gvinum 8 .
20689a7b2b7SSatoshi Asami.Sh SEE ALSO
207f6b811beSGiorgos Keramidas.Xr dd 1 ,
20889a7b2b7SSatoshi Asami.Xr ccd 4 ,
209f6b811beSGiorgos Keramidas.Xr disklabel 8 ,
2106d595743SDavid E. O'Brien.Xr fdisk 8 ,
211d1cd5e7cSJoel Dahl.Xr gvinum 8 ,
212d1cd5e7cSJoel Dahl.Xr rc 8
2136087df9eSRuslan Ermilov.Sh HISTORY
2146087df9eSRuslan ErmilovThe
2156087df9eSRuslan Ermilov.Nm
2166087df9eSRuslan Ermilovutility first appeared in
217494b4bb3SSevan Janiyan.Nx 1.1 .
218