Put in remaining pages and wiki contents.
[ikiwiki.git] / docs / handbook / handbook-raid.mdwn
1 \r
2 \r
3 ## 12.4 RAID \r
4 \r
5 ### 12.4.1 Software RAID \r
6 \r
7 #### 12.4.1.1 Concatenated Disk Driver (CCD) Configuration \r
8 \r
9 ***Original work by Christopher Shumway. ******Revised by Jim Brown. ***\r
10 \r
11 When choosing a mass storage solution the most important factors to consider are speed, reliability, and cost. It is rare to have all three in balance; normally a fast, reliable mass storage device is expensive, and to cut back on cost either speed or reliability must be sacrificed.\r
12 \r
13 In designing the system described below, cost was chosen as the most important factor, followed by speed, then reliability. Data transfer speed for this system is ultimately constrained by the network. And while reliability is very important, the CCD drive described below serves online data that is already fully backed up on CD-R's and can easily be replaced.\r
14 \r
15 Defining your own requirements is the first step in choosing a mass storage solution. If your requirements prefer speed or reliability over cost, your solution will differ from the system described in this section.\r
16 \r
17 ##### 12.4.1.1.1 Installing the Hardware \r
18 \r
19 In addition to the IDE system disk, three Western Digital 30GB, 5400 RPM IDE disks form the core of the CCD disk described below providing approximately 90GB of online storage. Ideally, each IDE disk would have its own IDE controller and cable, but to minimize cost, additional IDE controllers were not used. Instead the disks were configured with jumpers so that each IDE controller has one master, and one slave.\r
20 \r
21 Upon reboot, the system BIOS was configured to automatically detect the disks attached. More importantly, DragonFly detected them on reboot:\r
22 \r
23     \r
24     ad0: 19574MB <WDC WD205BA> [39770/16/63] at ata0-master UDMA33\r
25     ad1: 29333MB <WDC WD307AA> [59598/16/63] at ata0-slave UDMA33\r
26     ad2: 29333MB <WDC WD307AA> [59598/16/63] at ata1-master UDMA33\r
27     ad3: 29333MB <WDC WD307AA> [59598/16/63] at ata1-slave UDMA33\r
28 \r
29 \r
30  **Note:** If DragonFly does not detect all the disks, ensure that you have jumpered them correctly. Most IDE drives also have a ***Cable Select*** jumper. This is ***not*** the jumper for the master/slave relationship. Consult the drive documentation for help in identifying the correct jumper.\r
31 \r
32 Next, consider how to attach them as part of the file system. You should research both [vinum(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#vinum&section8) ([vinum-vinum.html Chapter 13]) and [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command=ccd&section=4). In this particular configuration, [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command=ccd&section=4) was chosen.\r
33 \r
34 ##### 12.4.1.1.2 Setting Up the CCD \r
35 \r
36 The driver [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#ccd&section4) allows you to take several identical disks and concatenate them into one logical file system. In order to use [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command=ccd&section=4), you need a kernel with [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command=ccd&section=4) support built in. Add this line to your kernel configuration file, rebuild, and reinstall the kernel:\r
37 \r
38     \r
39     pseudo-device   ccd     4\r
40 \r
41 \r
42 The [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#ccd&section4) support can also be loaded as a kernel loadable module.\r
43 \r
44 To set up [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#ccd&section4), you must first use [disklabel(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=disklabel&section=8) to label the disks:\r
45 \r
46     \r
47     disklabel -r -w ad1 auto\r
48     disklabel -r -w ad2 auto\r
49     disklabel -r -w ad3 auto\r
50 \r
51 \r
52 This creates a disklabel for `ad1c`, `ad2c` and `ad3c` that spans the entire disk.\r
53 \r
54 The next step is to change the disk label type. You can use [disklabel(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#disklabel&section8) to edit the disks:\r
55 \r
56     \r
57     disklabel -e ad1\r
58     disklabel -e ad2\r
59     disklabel -e ad3\r
60 \r
61 \r
62 This opens up the current disk label on each disk with the editor specified by the `EDITOR` environment variable, typically [vi(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#vi&section1).\r
63 \r
64 An unmodified disk label will look something like this:\r
65 \r
66     \r
67     16 partitions:\r
68     #        size   offset    fstype   [fsize bsize bps/cpg]\r
69       c: 60074784        0    unused        0     0     0   # (Cyl.    0 - 59597)\r
70 \r
71 \r
72 Add a new `e` partition for [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#ccd&section4) to use. This can usually be copied from the `c` partition, but the `fstype` ***must*** be 4.2BSD. The disk label should now look something like this:\r
73 \r
74     \r
75     16 partitions:\r
76     #        size   offset    fstype   [fsize bsize bps/cpg]\r
77       c: 60074784        0    unused        0     0     0   # (Cyl.    0 - 59597)\r
78       e: 60074784        0    4.2BSD        0     0     0   # (Cyl.    0 - 59597)\r
79 \r
80 \r
81 ##### 12.4.1.1.3 Building the File System \r
82 \r
83 The device node for `ccd0c` may not exist yet, so to create it, perform the following commands:\r
84 \r
85     \r
86     cd /dev\r
87     sh MAKEDEV ccd0\r
88 \r
89 \r
90 Now that you have all of the disks labeled, you must build the [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#ccd&section4). To do that, use [ccdconfig(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=ccdconfig&section=8), with options similar to the following:\r
91 \r
92     \r
93     ccdconfig ccd0./imagelib/callouts/1.png 32./imagelib/callouts/2.png 0./imagelib/callouts/3.png /dev/ad1e./imagelib/callouts/4.png /dev/ad2e /dev/ad3e\r
94 \r
95 \r
96 The use and meaning of each option is shown below:\r
97 \r
98 [ ./imagelib/callouts/1.png](raid.html#CO-CCD-DEV):: The first argument is the device to configure, in this case, `/dev/ccd0c`. The `/dev/` portion is optional.[ ./imagelib/callouts/2.png](raid.html#CO-CCD-INTERLEAVE):: The interleave for the file system. The interleave defines the size of a stripe in disk blocks, each normally 512 bytes. So, an interleave of 32 would be 16,384 bytes.[ ./imagelib/callouts/3.png](raid.html#CO-CCD-FLAGS):: Flags for [ccdconfig(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#ccdconfig&section8). If you want to enable drive mirroring, you can specify a flag here. This configuration does not provide mirroring for [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command=ccd&section=4), so it is set at 0 (zero).[ ./imagelib/callouts/4.png](raid.html#CO-CCD-DEVS):: The final arguments to [ccdconfig(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=ccdconfig&section=8) are the devices to place into the array. Use the complete pathname for each device.\r
99 \r
100 After running [ccdconfig(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#ccdconfig&section8) the [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command=ccd&section=4) is configured. A file system can be installed. Refer to [newfs(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=newfs&section=8) for options, or simply run:\r
101 \r
102     \r
103     newfs /dev/ccd0c\r
104 \r
105 \r
106 ##### 12.4.1.1.4 Making it All Automatic \r
107 \r
108 Generally, you will want to mount the [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#ccd&section4) upon each reboot. To do this, you must configure it first. Write out your current configuration to `/etc/ccd.conf` using the following command:\r
109 \r
110     \r
111     ccdconfig -g > /etc/ccd.conf\r
112 \r
113 \r
114 During reboot, the script `/etc/rc` runs `ccdconfig -C` if `/etc/ccd.conf` exists. This automatically configures the [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#ccd&section4) so it can be mounted.\r
115 \r
116  **Note:** If you are booting into single user mode, before you can [mount(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#mount&section8) the [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command=ccd&section=4), you need to issue the following command to configure the array:\r
117 \r
118     \r
119     ccdconfig -C\r
120 \r
121 \r
122 To automatically mount the [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#ccd&section4), place an entry for the [ccd(4)](http://leaf.dragonflybsd.org/cgi/web-man?command=ccd&section=4) in `/etc/fstab` so it will be mounted at boot time:\r
123 \r
124     \r
125     /dev/ccd0c              /media       ufs     rw      2       2\r
126 \r
127 \r
128 #### 12.4.1.2 The Vinum Volume Manager \r
129 \r
130 The Vinum Volume Manager is a block device driver which implements virtual disk drives. It isolates disk hardware from the block device interface and maps data in ways which result in an increase in flexibility, performance and reliability compared to the traditional slice view of disk storage. [vinum(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#vinum&section8) implements the RAID-0, RAID-1 and RAID-5 models, both individually and in combination.\r
131 \r
132 See [vinum-vinum.html Chapter 13] for more information about [vinum(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#vinum&section8).\r
133 \r
134 ### 12.4.2 Hardware RAID \r
135 \r
136 DragonFly also supports a variety of hardware RAID controllers. These devices control a RAID subsystem without the need for DragonFly specific software to manage the array.\r
137 \r
138 Using an on-card BIOS, the card controls most of the disk operations itself. The following is a brief setup description using a Promise IDE RAID controller. When this card is installed and the system is started up, it displays a prompt requesting information. Follow the instructions to enter the card's setup screen. From here, you have the ability to combine all the attached drives. After doing so, the disk(s) will look like a single drive to DragonFly. Other RAID levels can be set up accordingly.\r
139 \r
140 ### 12.4.3 Rebuilding ATA RAID1 Arrays \r
141 \r
142 DragonFly allows you to hot-replace a failed disk in an array. This requires that you catch it before you reboot.\r
143 \r
144 You will probably see something like the following in `/var/log/messages` or in the [dmesg(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#dmesg&section8) output:\r
145 \r
146     \r
147     ad6 on monster1 suffered a hard error.\r
148     ad6: READ command timeout tag#0 serv0 - resetting\r
149     ad6: trying fallback to PIO mode\r
150     ata3: resetting devices .. done\r
151     ad6: hard error reading fsbn 1116119 of 0-7 (ad6 bn 1116119; cn 1107 tn 4 sn 11) status#59 error40\r
152     ar0: WARNING - mirror lost\r
153 \r
154 \r
155 Using [atacontrol(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#atacontrol&section8), check for further information:\r
156 \r
157     \r
158     # atacontrol list\r
159     ATA channel 0:\r
160         Master:      no device present\r
161         Slave:   acd0 <HL-DT-ST CD-ROM GCR-8520B/1.00> ATA/ATAPI rev 0\r
162     \r
163     ATA channel 1:\r
164         Master:      no device present\r
165         Slave:       no device present\r
166     \r
167     ATA channel 2:\r
168         Master:  ad4 <MAXTOR 6L080J4/A93.0500> ATA/ATAPI rev 5\r
169         Slave:       no device present\r
170     \r
171     ATA channel 3:\r
172         Master:  ad6 <MAXTOR 6L080J4/A93.0500> ATA/ATAPI rev 5\r
173         Slave:       no device present\r
174     \r
175     # atacontrol status ar0\r
176     ar0: ATA RAID1 subdisks: ad4 ad6 status: DEGRADED\r
177 \r
178 \r
179   1. You will first need to detach the disk from the array so that you can safely remove it:\r
180       \r
181       # atacontrol detach 3\r
182   \r
183   1. Replace the disk.\r
184   1. Reattach the disk as a spare:\r
185       \r
186       # atacontrol attach 3\r
187       Master:  ad6 <MAXTOR 6L080J4/A93.0500> ATA/ATAPI rev 5\r
188       Slave:   no device present\r
189   \r
190   1. Rebuild the array:\r
191       \r
192       # atacontrol rebuild ar0\r
193   \r
194   1. The rebuild command hangs until complete. However, it is possible to open another terminal (using  **Alt** +***'F`***n***`***') and check on the progress by issuing the following command:\r
195       \r
196       # dmesg | tail -10\r
197       [output removed]\r
198       ad6: removed from configuration\r
199       ad6: deleted from ar0 disk1\r
200       ad6: inserted into ar0 disk1 as spare\r
201       # atacontrol status ar0\r
202       ar0: ATA RAID1 subdisks: ad4 ad6 status: REBUILDING 0% completed\r
203   \r
204   1. Wait until this operation completes.\r
205 \r
206 \r
207 \r
208 CategoryHandbook\r
209 CategoryHandbook-storage\r