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