]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/vinum/vinum.8
This commit was generated by cvs2svn to compensate for changes in r92289,
[FreeBSD/FreeBSD.git] / sbin / vinum / vinum.8
1 .\"  Hey, Emacs, edit this file in -*- nroff-fill -*- mode
2 .\"-
3 .\" Copyright (c) 1997, 1998
4 .\"     Nan Yang Computer Services Limited.  All rights reserved.
5 .\"
6 .\"  This software is distributed under the so-called ``Berkeley
7 .\"  License'':
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 Nan Yang Computer
20 .\"      Services Limited.
21 .\" 4. Neither the name of the Company nor the names of its contributors
22 .\"    may be used to endorse or promote products derived from this software
23 .\"    without specific prior written permission.
24 .\"
25 .\" This software is provided ``as is'', and any express or implied
26 .\" warranties, including, but not limited to, the implied warranties of
27 .\" merchantability and fitness for a particular purpose are disclaimed.
28 .\" In no event shall the company or contributors be liable for any
29 .\" direct, indirect, incidental, special, exemplary, or consequential
30 .\" damages (including, but not limited to, procurement of substitute
31 .\" goods or services; loss of use, data, or profits; or business
32 .\" interruption) however caused and on any theory of liability, whether
33 .\" in contract, strict liability, or tort (including negligence or
34 .\" otherwise) arising in any way out of the use of this software, even if
35 .\" advised of the possibility of such damage.
36 .\"
37 .\" $Id: vinum.8,v 1.15 2001/05/14 01:10:37 grog Exp grog $
38 .\" $FreeBSD$
39 .\"
40 .Dd December 20, 2000
41 .Dt VINUM 8
42 .Os
43 .Sh NAME
44 .Nm vinum
45 .Nd Logical Volume Manager control program
46 .Sh SYNOPSIS
47 .Nm
48 .Op Ar command
49 .Op Fl options
50 .Sh COMMANDS
51 .Bl -tag -width indent
52 .It Ic attach Ar plex volume Op Cm rename
53 .It Xo
54 .Ic attach Ar subdisk plex
55 .Op Ar offset
56 .Op Cm rename
57 .Xc
58 Attach a plex to a volume, or a subdisk to a plex.
59 .It Xo
60 .Ic checkparity Ar plex
61 .Op Fl f
62 .Op Fl v
63 .Xc
64 Check the parity blocks of a RAID-4 or RAID-5 plex.
65 .It Xo
66 .Ic concat
67 .Op Fl f
68 .Op Fl n Ar name
69 .Op Fl v
70 .Ar drives
71 .Xc
72 Create a concatenated volume from the specified drives.
73 .It Xo
74 .Ic create
75 .Op Fl f
76 .Ar description-file
77 .Xc
78 Create a volume as described in
79 .Ar description-file .
80 .It Ic debug
81 Cause the volume manager to enter the kernel debugger.
82 .It Ic debug Ar flags
83 Set debugging flags.
84 .It Xo
85 .Ic detach
86 .Op Fl f
87 .Op Ar plex | subdisk
88 .Xc
89 Detach a plex or subdisk from the volume or plex to which it is attached.
90 .It Ic dumpconfig Op Ar drive ...
91 List the configuration information stored on the specified drives, or all drives
92 in the system if no drive names are specified.
93 .It Xo
94 .Ic info
95 .Op Fl v
96 .Op Fl V
97 .Xc
98 List information about volume manager state.
99 .It Xo
100 .Ic init
101 .Op Fl S Ar size
102 .Op Fl w
103 .Ar plex | subdisk
104 .Xc
105 .\" XXX
106 Initialize the contents of a subdisk or all the subdisks of a plex to all zeros.
107 .It Ic label Ar volume
108 Create a volume label.
109 .It Xo
110 .Ic l | list
111 .Op Fl r
112 .Op Fl s
113 .Op Fl v
114 .Op Fl V
115 .Op Ar volume | plex | subdisk
116 .Xc
117 List information about specified objects.
118 .It Xo
119 .Ic ld
120 .Op Fl r
121 .Op Fl s
122 .Op Fl v
123 .Op Fl V
124 .Op Ar volume
125 .Xc
126 List information about drives.
127 .It Xo
128 .Ic ls
129 .Op Fl r
130 .Op Fl s
131 .Op Fl v
132 .Op Fl V
133 .Op Ar subdisk
134 .Xc
135 List information about subdisks.
136 .It Xo
137 .Ic lp
138 .Op Fl r
139 .Op Fl s
140 .Op Fl v
141 .Op Fl V
142 .Op Ar plex
143 .Xc
144 List information about plexes.
145 .It Xo
146 .Ic lv
147 .Op Fl r
148 .Op Fl s
149 .Op Fl v
150 .Op Fl V
151 .Op Ar volume
152 .Xc
153 List information about volumes.
154 .It Ic makedev
155 Remake the device nodes in
156 .Pa /dev/vinum .
157 .It Xo
158 .Ic mirror
159 .Op Fl f
160 .Op Fl n Ar name
161 .Op Fl s
162 .Op Fl v
163 .Ar drives
164 .Xc
165 Create a mirrored volume from the specified drives.
166 .It Xo
167 .Ic move | mv
168 .Fl f
169 .Ar drive object ...
170 .Xc
171 Move the object(s) to the specified drive.
172 .It Ic printconfig Op Ar file
173 Write a copy of the current configuration to
174 .Ar file .
175 .It Ic quit
176 Exit the
177 .Nm
178 program when running in interactive mode.  Normally this would be done by
179 entering the
180 .Dv EOF
181 character.
182 .It Ic read Ar disk ...
183 Read the
184 .Nm
185 configuration from the specified disks.
186 .It Xo
187 .Ic rename Op Fl r
188 .Op Ar drive | subdisk | plex | volume
189 .Ar newname
190 .Xc
191 Change the name of the specified object.
192 .\" XXX
193 .\".It Ic replace Ar drive newdrive
194 .\"Move all the subdisks from the specified drive onto the new drive.
195 .It Xo
196 .Ic rebuildparity Ar plex Op Fl f
197 .Op Fl v
198 .Op Fl V
199 .Xc
200 Rebuild the parity blocks of a RAID-4 or RAID-5 plex.
201 .It Ic resetconfig
202 Reset the complete
203 .Nm
204 configuration.
205 .It Xo
206 .Ic resetstats
207 .Op Fl r
208 .Op Ar volume | plex | subdisk
209 .Xc
210 Reset statistisc counters for the specified objects, or for all objects if none
211 are specified.
212 .It Xo
213 .Ic rm
214 .Op Fl f
215 .Op Fl r
216 .Ar volume | plex | subdisk
217 .Xc
218 Remove an object.
219 .It Ic saveconfig
220 Save
221 .Nm
222 configuration to disk after configuration failures.
223 .\" XXX
224 .\".It Xo
225 .\".Ic set
226 .\".Op Fl f
227 .\".Ar state
228 .\".Ar volume | plex | subdisk | disk
229 .\".Xc
230 .\"Set the state of the object to
231 .\".Ar state .
232 .It Ic setdaemon Op Ar value
233 Set daemon configuration.
234 .It Xo
235 .Ic setstate
236 .Ar state
237 .Op Ar volume | plex | subdisk | drive
238 .Xc
239 Set state without influencing other objects, for diagnostic purposes only.
240 .It Ic start
241 Read configuration from all vinum drives.
242 .It Xo
243 .Ic start
244 .Op Fl i Ar interval
245 .Op Fl S Ar size
246 .Op Fl w
247 .Ar volume | plex | subdisk
248 .Xc
249 Allow the system to access the objects.
250 .It Xo
251 .Ic stop
252 .Op Fl f
253 .Op Ar volume | plex | subdisk
254 .Xc
255 Terminate access to the objects, or stop
256 .Nm
257 if no parameters are specified.
258 .It Xo
259 .Ic stripe
260 .Op Fl f
261 .Op Fl n Ar name
262 .Op Fl v
263 .Ar drives
264 .Xc
265 Create a striped volume from the specified drives.
266 .El
267 .Sh DESCRIPTION
268 .Nm
269 is a utility program to communicate with the kernel component of the Vinum
270 logical volume manager.
271 .Nm
272 is designed either for interactive use, when started without command line
273 arguments, or to execute a single command if the command is supplied on the
274 command line.  In interactive mode,
275 .Nm
276 maintains a command line history.
277 .Sh OPTIONS
278 .Nm
279 commands may optionally be followed by an option.  Any of the following options
280 may be specified with any command, but in some cases the options are ignored.
281 For example, the
282 .Ic stop
283 command ignores the
284 .Fl v
285 and
286 .Fl V
287 options.
288 .Bl -tag -width indent
289 .It Fl f
290 The
291 .Fl f
292 .Pq Dq force
293 option overrides safety checks.  Use with extreme care.  This option is for
294 emergency use only.  For example, the command
295 .Pp
296 .Dl rm -f myvolume
297 .Pp
298 removes
299 .Ar myvolume
300 even if it is open.  Any subsequent access to the volume will almost certainly
301 cause a panic.
302 .It Fl i Ar millisecs
303 When performing the
304 .Ic init
305 and
306 .Ic start
307 commands, wait
308 .Ar millisecs
309 milliseconds between copying each block.  This lowers the load on the system.
310 .It Fl n Ar name
311 Use the
312 .Fl n
313 option to specify a volume name to the simplified configuration commands
314 .Ic concat , mirror
315 and
316 .Ic stripe .
317 .It Fl r
318 The
319 .Fl r
320 .Pq Dq recursive
321 option is used by the list commands to display information not
322 only about the specified objects, but also about subordinate objects.  For
323 example, in conjunction with the
324 .Ic lv
325 command, the
326 .Fl r
327 option will also show information about the plexes and subdisks belonging to the
328 volume.
329 .It Fl s
330 The
331 .Fl s
332 .Pq Dq statistics
333 option is used by the list commands to display statistical information.  The
334 .Ic mirror
335 command also uses this option to specify that it should create striped plexes.
336 .It Fl S Ar size
337 The
338 .Fl S
339 option specifies the transfer size for the
340 .Ic init
341 and
342 .Ic start
343 commands.
344 .It Fl v
345 The
346 .Fl v
347 .Pq Dq verbose
348 option can be used to request more detailed information.
349 .It Fl V
350 The
351 .Fl V
352 .Pq Dq Very verbose
353 option can be used to request more detailed information than the
354 .Fl v
355 option provides.
356 .It Fl w
357 The
358 .Fl w
359 .Pq Dq wait
360 option tells
361 .Nm
362 to wait for completion of commands which normally run in the background, such as
363 .Ic init .
364 .El
365 .Sh COMMANDS IN DETAIL
366 .Nm
367 commands perform the following functions:
368 .Pp
369 .Bl -tag -width indent -compact
370 .It Ic attach Ar plex volume Op Cm rename
371 .It Xo
372 .Ic attach Ar subdisk plex
373 .Op Ar offset
374 .Op Cm rename
375 .Xc
376 .Nm Ic attach
377 inserts the specified plex or subdisk in a volume or plex.  In the case of a
378 subdisk, an offset in the plex may be specified.  If it is not, the subdisk will
379 be attached at the first possible location.  After attaching a plex to a
380 non-empty volume,
381 .Nm
382 reintegrates the plex.
383 .Pp
384 If the keyword
385 .Cm rename
386 is specified,
387 .Nm
388 renames the object (and in the case of a plex, any subordinate subdisks) to fit
389 in with the default
390 .Nm
391 naming convention.  To rename the object to any other name, use the
392 .Ic rename
393 command.
394 .Pp
395 A number of considerations apply to attaching subdisks:
396 .Bl -bullet
397 .It
398 Subdisks can normally only be attached to concatenated plexes.
399 .It
400 If a striped or RAID-5 plex is missing a subdisk (for example after drive
401 failure), it should be replaced by a subdisk of the same size only.
402 .It
403 In order to add further subdisks to a striped or RAID-5 plex, use the
404 .Fl f
405 (force) option.  This will corrupt the data in the plex.
406 .\"No other attachment of
407 .\"subdisks is currently allowed for striped and RAID-5 plexes.
408 .It
409 For concatenated plexes, the
410 .Ar offset
411 parameter specifies the offset in blocks from the beginning of the plex.  For
412 striped and RAID-5 plexes, it specifies the offset of the first block of the
413 subdisk: in other words, the offset is the numerical position of the subdisk
414 multiplied by the stripe size.  For example, in a plex with stripe size 271k,
415 the first subdisk will have offset 0, the second offset 271k, the third 542k,
416 etc.  This calculation ignores parity blocks in RAID-5 plexes.
417 .El
418 .Pp
419 .It Xo
420 .Ic checkparity
421 .Ar plex
422 .Op Fl f
423 .Op Fl v
424 .Xc
425 Check the parity blocks on the specified RAID-4 or RAID-5 plex.  This operation
426 maintains a pointer in the plex, so it can be stopped and later restarted from
427 the same position if desired.  In addition, this pointer is used by the
428 .Ic rebuildparity
429 command, so rebuilding the parity blocks need only start at the location where
430 the first parity problem has been detected.
431 .Pp
432 If the
433 .Fl f
434 flag is specified,
435 .Ic checkparity
436 starts checking at the beginning of the plex.  If the
437 .Fl v
438 flag is specified,
439 .Ic checkparity
440 prints a running progress report.
441 .Pp
442 .It Xo
443 .Ic concat
444 .Op Fl f
445 .Op Fl n Ar name
446 .Op Fl v
447 .Ar drives
448 .Xc
449 The
450 .Ic concat
451 command provides a simplified alternative to the
452 .Ic create
453 command for creating volumes with a single concatenated plex.  The largest
454 contiguous space available on each drive is used to create the subdisks for the
455 plexes.
456 .Pp
457 Normally, the
458 .Ic concat
459 command creates an arbitrary name for the volume and its components.  The name
460 is composed of the text
461 .Dq Li vinum
462 and a small integer, for example
463 .Dq Li vinum3 .
464 You can override this with the
465 .Fl n Ar name
466 option, which assigns the name specified to the volume.  The plexes and subdisks
467 are named after the volume in the default manner.
468 .Pp
469 There is no choice of name for the drives.  If the drives have already been
470 initialized as
471 .Nm
472 drives, the name remains.  Otherwise the drives are given names starting with
473 the text
474 .Dq Li vinumdrive
475 and a small integer, for example
476 .Dq Li vinumdrive7 .
477 As with the
478 .Ic create
479 command, the
480 .Fl f
481 option can be used to specify that a previous name should be overwritten.  The
482 .Fl v
483 is used to specify verbose output.
484 .Pp
485 See the section
486 .Sx SIMPLIFIED CONFIGURATION
487 below for some examples of this
488 command.
489 .Pp
490 .It Xo
491 .Ic create
492 .Op Fl f
493 .Ar description-file
494 .Xc
495 .Nm Ic create
496 is used to create any object.  In view of the relatively complicated
497 relationship and the potential dangers involved in creating a
498 .Nm
499 object, there is no interactive interface to this function.  If you do not
500 specify a file name,
501 .Nm
502 starts an editor on a temporary file.  If the environment variable
503 .Ev EDITOR
504 is set,
505 .Nm
506 starts this editor.  If not, it defaults to
507 .Nm vi .
508 See the section
509 .Sx CONFIGURATION FILE
510 below for more information on the format of
511 this file.
512 .Pp
513 Note that the
514 .Nm Ic create
515 function is additive: if you run it multiple times, you will create multiple
516 copies of all unnamed objects.
517 .Pp
518 Normally the
519 .Ic create
520 command will not change the names of existing
521 .Nm
522 drives, in order to avoid accidentally erasing them.  The correct way to dispose
523 of no longer wanted
524 .Nm
525 drives is to reset the configuration with the
526 .Ic resetconfig
527 command.  In some cases, however, it may be necessary to create new data on
528 .Nm
529 drives which can no longer be started.  In this case, use the
530 .Ic create Fl f
531 command.
532 .Pp
533 .It Ic debug
534 .Nm Ic debug ,
535 without any arguments, is used to enter the remote kernel debugger.  It is only
536 activated if
537 .Nm
538 is built with the
539 .Dv VINUMDEBUG
540 option.  This option will stop the execution of the operating system until the
541 kernel debugger is exited.  If remote debugging is set and there is no remote
542 connection for a kernel debugger, it will be necessary to reset the system and
543 reboot in order to leave the debugger.
544 .Pp
545 .It Ic debug Ar flags
546 Set a bit mask of internal debugging flags.  These will change without warning
547 as the product matures; to be certain, read the header file
548 .Aq Pa sys/dev/vinumvar.h .
549 The bit mask is composed of the following values:
550 .Bl -tag -width indent
551 .It Dv DEBUG_ADDRESSES Pq No 1
552 Show buffer information during requests
553 .\".It Dv DEBUG_NUMOUTPUT Pq No 2
554 .\"Show the value of
555 .\".Va vp->v_numoutput .
556 .It Dv DEBUG_RESID Pq No 4
557 Go into debugger in
558 .Fn complete_rqe .
559 .It Dv DEBUG_LASTREQS Pq No 8
560 Keep a circular buffer of last requests.
561 .It Dv DEBUG_REVIVECONFLICT Pq No 16
562 Print info about revive conflicts.
563 .It Dv DEBUG_EOFINFO Pq No 32
564 Print information about internal state when returning an
565 .Dv EOF
566 on a striped plex.
567 .It Dv DEBUG_MEMFREE Pq No 64
568 Maintain a circular list of the last memory areas freed by the memory allocator.
569 .It Dv DEBUG_REMOTEGDB Pq No 256
570 Go into remote
571 .Nm gdb
572 when the
573 .Ic debug
574 command is issued.
575 .It Dv DEBUG_WARNINGS Pq No 512
576 Print some warnings about minor problems in the implementation.
577 .El
578 .Pp
579 .It Ic detach Oo Fl f Oc Ar plex
580 .It Ic detach Oo Fl f Oc Ar subdisk
581 .Nm Ic detach
582 removes the specified plex or subdisk from the volume or plex to which it is
583 attached.  If removing the object would impair the data integrity of the volume,
584 the operation will fail unless the
585 .Fl f
586 option is specified.  If the object is named after the object above it (for
587 example, subdisk
588 .Li vol1.p7.s0
589 attached to plex
590 .Li vol1.p7 ) ,
591 the name will be changed
592 by prepending the text
593 .Dq Li ex-
594 (for example,
595 .Li ex-vol1.p7.s0 ) .
596 If necessary, the name will be truncated in the
597 process.
598 .Pp
599 .Ic detach
600 does not reduce the number of subdisks in a striped or RAID-5 plex.  Instead,
601 the subdisk is marked absent, and can later be replaced with the
602 .Ic attach
603 command.
604 .Pp
605 .It Ic dumpconfig Op Ar drive ...
606 .Pp
607 .Nm Ic dumpconfig
608 shows the configuration information stored on the specified drives.  If no drive
609 names are specified,
610 .Ic dumpconfig
611 searches all drives on the system for Vinum partitions and dumps the
612 information.  If configuration updates are disabled, it is possible that this
613 information is not the same as the information returned by the
614 .Ic list
615 command.  This command is used primarily for maintenance and debugging.
616 .Pp
617 .It Ic info
618 .Nm Ic info
619 displays information about
620 .Nm
621 memory usage.  This is intended primarily for debugging.  With the
622 .Fl v
623 option, it will give detailed information about the memory areas in use.
624 .Pp
625 With the
626 .Fl V
627 option,
628 .Ic info
629 displays information about the last up to 64 I/O requests handled by the
630 .Nm
631 driver.  This information is only collected if debug flag 8 is set.  The format
632 looks like:
633 .Bd -literal
634 vinum -> info -V
635 Flags: 0x200    1 opens
636 Total of 38 blocks malloced, total memory: 16460
637 Maximum allocs:       56, malloc table at 0xf0f72dbc
638
639 Time             Event       Buf        Dev     Offset          Bytes   SD      SDoff   Doffset Goffset
640
641 14:40:00.637758 1VS Write 0xf2361f40    91.3  0x10            16384
642 14:40:00.639280 2LR Write 0xf2361f40    91.3  0x10            16384
643 14:40:00.639294 3RQ Read  0xf2361f40    4.39   0x104109        8192    19      0       0       0
644 14:40:00.639455 3RQ Read  0xf2361f40    4.23   0xd2109         8192    17      0       0       0
645 14:40:00.639529 3RQ Read  0xf2361f40    4.15   0x6e109         8192    16      0       0       0
646 14:40:00.652978 4DN Read  0xf2361f40    4.39   0x104109        8192    19      0       0       0
647 14:40:00.667040 4DN Read  0xf2361f40    4.15   0x6e109         8192    16      0       0       0
648 14:40:00.668556 4DN Read  0xf2361f40    4.23   0xd2109         8192    17      0       0       0
649 14:40:00.669777 6RP Write 0xf2361f40    4.39   0x104109        8192    19      0       0       0
650 14:40:00.685547 4DN Write 0xf2361f40    4.39   0x104109        8192    19      0       0       0
651 11:11:14.975184 Lock      0xc2374210    2      0x1f8001
652 11:11:15.018400 7VS Write 0xc2374210           0x7c0           32768   10
653 11:11:15.018456 8LR Write 0xc2374210    13.39  0xcc0c9         32768
654 11:11:15.046229 Unlock    0xc2374210    2      0x1f8001
655 .Ed
656 .Pp
657 The
658 .Ar Buf
659 field always contains the address of the user buffer header.  This can be used
660 to identify the requests associated with a user request, though this is not 100%
661 reliable: theoretically two requests in sequence could use the same buffer
662 header, though this is not common.  The beginning of a request can be identified
663 by the event
664 .Ar 1VS
665 or
666 .Ar 7VS .
667 The first example above shows the requests involved in a user request.  The
668 second is a subdisk I/O request with locking.
669 .Pp
670 The
671 .Ar Event
672 field contains information related to the sequence of events in the request
673 chain.  The digit
674 .Ar 1
675 to
676 .Ar 6
677 indicates the approximate sequence of events, and the two-letter abbreviation is
678 a mnemonic for the location:
679 .Bl -tag -width Lockwait
680 .It 1VS
681 (vinumstrategy) shows information about the user request on entry to
682 .Fn vinumstrategy .
683 The device number is the
684 .Nm
685 device, and offset and length are the user parameters.  This is always the
686 beginning of a request sequence.
687 .It 2LR
688 (launch_requests) shows the user request just prior to launching the low-level
689 .Nm
690 requests in the function
691 .Fn launch_requests .
692 The parameters should be the same as in the
693 .Ar 1VS
694 information.
695 .El
696 .Pp
697 In the following requests,
698 .Ar Dev
699 is the device number of the associated disk partition,
700 .Ar Offset
701 is the offset from the beginning of the partition,
702 .Ar SD
703 is the subdisk index in
704 .Va vinum_conf ,
705 .Ar SDoff
706 is the offset from the beginning of the subdisk,
707 .Ar Doffset
708 is the offset of the associated data request, and
709 .Ar Goffset
710 is the offset of the associated group request, where applicable.
711 .Bl -tag -width Lockwait
712 .It 3RQ
713 (request) shows one of possibly several low-level
714 .Nm
715 requests which are launched to satisfy the high-level request.  This information
716 is also logged in
717 .Fn launch_requests .
718 .It 4DN
719 (done) is called from
720 .Fn complete_rqe ,
721 showing the completion of a request.  This completion should match a request
722 launched either at stage
723 .Ar 4DN
724 from
725 .Fn launch_requests ,
726 or from
727 .Fn complete_raid5_write
728 at stage
729 .Ar 5RD
730 or
731 .Ar 6RP .
732 .It 5RD
733 (RAID-5 data) is called from
734 .Fn complete_raid5_write
735 and represents the data written to a RAID-5 data stripe after calculating
736 parity.
737 .It 6RP
738 (RAID-5 parity) is called from
739 .Fn complete_raid5_write
740 and represents the data written to a RAID-5 parity stripe after calculating
741 parity.
742 .It 7VS
743 shows a subdisk I/O request.  These requests are usually internal to
744 .Nm
745 for operations like initialization or rebuilding plexes.
746 .It 8LR
747 shows the low-level operation generated for a subdisk I/O request.
748 .It Lockwait
749 specifies that the process is waiting for a range lock.  The parameters are the
750 buffer header associated with the request, the plex number and the block number.
751 For internal reasons the block number is one higher than the address of the
752 beginning of the stripe.
753 .It Lock
754 specifies that a range lock has been obtained.  The parameters are the same as
755 for the range lock.
756 .It Unlock
757 specifies that a range lock has been released.  The parameters are the same as
758 for the range lock.
759 .El
760 .\" XXX
761 .Pp
762 .It Xo
763 .Ic init
764 .Op Fl S Ar size
765 .Op Fl w
766 .Ar plex | subdisk
767 .Xc
768 .Nm Ic init
769 initializes a subdisk by writing zeroes to it.  You can initialize all subdisks
770 in a plex by specifying the plex name.  This is the only way to ensure
771 consistent data in a plex.  You must perform this initialization before using a
772 RAID-5 plex.  It is also recommended for other new plexes.
773 .Nm
774 initializes all subdisks of a plex in parallel.  Since this operation can take a
775 long time, it is normally performed in the background.  If you want to wait for
776 completion of the command, use the
777 .Fl w
778 (wait) option.
779 .Pp
780 Specify the
781 .Fl S
782 option if you want to write blocks of a different size from the default value of
783 16 kB.
784 .Nm
785 prints a console message when the initialization is complete.
786 .Pp
787 .It Ic label Ar volume
788 The
789 .Ic label
790 command writes a
791 .Em ufs
792 style volume label on a volume.  It is a simple alternative to an appropriate
793 call to
794 .Ic disklabel .
795 This is needed because some
796 .Em ufs
797 commands still read the disk to find the label instead of using the correct
798 .Xr ioctl 2
799 call to access it.
800 .Nm
801 maintains a volume label separately from the volume data, so this command is not
802 needed for
803 .Xr newfs 8 .
804 This command is deprecated.
805 .Pp
806 .It Xo
807 .Ic list
808 .Op Fl r
809 .Op Fl V
810 .Op Ar volume | plex | subdisk
811 .Xc
812 .It Xo
813 .Ic l
814 .Op Fl r
815 .Op Fl V
816 .Op Ar volume | plex | subdisk
817 .Xc
818 .It Xo
819 .Ic ld
820 .Op Fl r
821 .Op Fl s
822 .Op Fl v
823 .Op Fl V
824 .Op Ar volume
825 .Xc
826 .It Xo
827 .Ic ls
828 .Op Fl r
829 .Op Fl s
830 .Op Fl v
831 .Op Fl V
832 .Op Ar subdisk
833 .Xc
834 .It Xo
835 .Ic lp
836 .Op Fl r
837 .Op Fl s
838 .Op Fl v
839 .Op Fl V
840 .Op Ar plex
841 .Xc
842 .It Xo
843 .Ic lv
844 .Op Fl r
845 .Op Fl s
846 .Op Fl v
847 .Op Fl V
848 .Op Ar volume
849 .Xc
850 .Ic list
851 is used to show information about the specified object.  If the argument is
852 omitted, information is shown about all objects known to
853 .Nm .
854 The
855 .Ic l
856 command is a synonym for
857 .Ic list .
858 .Pp
859 The
860 .Fl r
861 option relates to volumes and plexes: if specified, it recursively lists
862 information for the subdisks and (for a volume) plexes subordinate to the
863 objects.  The commands
864 .Ic lv , lp , ls
865 and
866 .Ic ld
867 list only volumes, plexes, subdisks and drives respectively.  This is
868 particularly useful when used without parameters.
869 .Pp
870 The
871 .Fl s
872 option causes
873 .Nm
874 to output device statistics, the
875 .Fl v
876 (verbose) option causes some additional information to be output, and the
877 .Fl V
878 causes considerable additional information to be output.
879 .Pp
880 .It Ic makedev
881 The
882 .Ic makedev
883 command removes the directory
884 .Pa /dev/vinum
885 and recreates it with device nodes
886 which reflect the current configuration.  This command is not intended for
887 general use, and is provided for emergency use only.
888 .Pp
889 .It Xo
890 .Ic mirror
891 .Op Fl f
892 .Op Fl n Ar name
893 .Op Fl s
894 .Op Fl v
895 .Ar drives
896 .Xc
897 The
898 .Ic mirror
899 command provides a simplified alternative to the
900 .Ic create
901 command for creating mirrored volumes.  Without any options, it creates a RAID-1
902 (mirrored) volume with two concatenated plexes.  The largest contiguous space
903 available on each drive is used to create the subdisks for the plexes.  The
904 first plex is built from the odd-numbered drives in the list, and the second
905 plex is built from the even-numbered drives.  If the drives are of different
906 sizes, the plexes will be of different sizes.
907 .Pp
908 If the
909 .Fl s
910 option is provided,
911 .Ic mirror
912 builds striped plexes with a stripe size of 279 kB.  The size of the subdisks in
913 each plex is the size of the smallest contiguous storage available on any of the
914 drives which form the plex.  Again, the plexes may differ in size.
915 .Pp
916 Normally, the
917 .Ic mirror
918 command creates an arbitrary name for the volume and its components.  The name
919 is composed of the text
920 .Dq Li vinum
921 and a small integer, for example
922 .Dq Li vinum3 .
923 You can override this with the
924 .Fl n Ar name
925 option, which assigns the name specified to the volume.  The plexes and subdisks
926 are named after the volume in the default manner.
927 .Pp
928 There is no choice of name for the drives.  If the drives have already been
929 initialized as
930 .Nm
931 drives, the name remains.  Otherwise the drives are given names starting with
932 the text
933 .Dq Li vinumdrive
934 and a small integer, for example
935 .Dq Li vinumdrive7 .
936 As with the
937 .Ic create
938 command, the
939 .Fl f
940 option can be used to specify that a previous name should be overwritten.  The
941 .Fl v
942 is used to specify verbose output.
943 .Pp
944 See the section
945 .Sx SIMPLIFIED CONFIGURATION
946 below for some examples of this
947 command.
948 .Pp
949 .It Ic mv Fl f Ar drive object ...
950 .It Ic move Fl f Ar drive object ...
951 Move all the subdisks from the specified objects onto the new drive.  The
952 objects may be subdisks, drives or plexes.  When drives or plexes are specified,
953 all subdisks associated with the object are moved.
954 .Pp
955 The
956 .Fl f
957 option is required for this function, since it currently does not preserve the
958 data in the subdisk.  This functionality will be added at a later date.  In this
959 form, however, it is suited to recovering a failed disk drive.
960 .Pp
961 .It Ic printconfig Op Ar file
962 Write a copy of the current configuration to
963 .Ar file
964 in a format that can be used to recreate the
965 .Nm
966 configuration.  Unlike the configuration saved on disk, it includes definitions
967 of the drives.  If you omit
968 .Ar file ,
969 .Nm
970 writes the list to
971 .Dv stdout .
972 .Pp
973 .It Ic quit
974 Exit the
975 .Nm
976 program when running in interactive mode.  Normally this would be done by
977 entering the
978 .Dv EOF
979 character.
980 .Pp
981 .It Ic read Ar disk ...
982 The
983 .Ic read
984 command scans the specified disks for
985 .Nm
986 partitions containing previously created configuration information.  It reads
987 the configuration in order from the most recently updated to least recently
988 updated configuration.
989 .Nm
990 maintains an up-to-date copy of all configuration information on each disk
991 partition.  You must specify all of the slices in a configuration as the
992 parameter to this command.
993 .Pp
994 The
995 .Ic read
996 command is intended to selectively load a
997 .Nm
998 configuration on a system which has other
999 .Nm
1000 partitions.  If you want to start all partitions on the system, it is easier to
1001 use the
1002 .Ic start
1003 command.
1004 .Pp
1005 If
1006 .Nm
1007 encounters any errors during this command, it will turn off automatic
1008 configuration update to avoid corrupting the copies on disk.  This will also
1009 happen if the configuration on disk indicates a configuration error (for
1010 example, subdisks which do not have a valid space specification).  You can turn
1011 the updates on again with the
1012 .Ic setdaemon
1013 and
1014 .Ic saveconfig
1015 commands.  Reset bit 2 (numerical value 4) of the daemon options mask to
1016 re-enable configuration saves.
1017 .Pp
1018 .It Xo
1019 .Ic rebuildparity
1020 .Ar plex
1021 .Op Fl f
1022 .Op Fl v
1023 .Op Fl V
1024 .Xc
1025 Rebuild the parity blocks on the specified RAID-4 or RAID-5 plex.  This
1026 operation maintains a pointer in the plex, so it can be stopped and later
1027 restarted from the same position if desired.  In addition, this pointer is used
1028 by the
1029 .Ic checkparity
1030 command, so rebuilding the parity blocks need only start at the location where
1031 the first parity problem has been detected.
1032 .Pp
1033 If the
1034 .Fl f
1035 flag is specified,
1036 .Ic rebuildparity
1037 starts rebuilding at the beginning of the plex.  If the
1038 .Fl v
1039 flag is specified,
1040 .Ic rebuildparity
1041 first checks the existing parity blocks prints information about those found to
1042 be incorrect before rebuilding.  If the
1043 .Fl V
1044 flag is specified,
1045 .Ic rebuildparity
1046 prints a running progress report.
1047 .Pp
1048 .It Xo
1049 .Ic rename
1050 .Op Fl r
1051 .Op Ar drive | subdisk | plex | volume
1052 .Ar newname
1053 .Xc
1054 Change the name of the specified object.  If the
1055 .Fl r
1056 option is specified, subordinate objects will be named by the default rules:
1057 plex names will be formed by appending
1058 .Li .p Ns Ar number
1059 to the volume name, and
1060 subdisk names will be formed by appending
1061 .Li .s Ns Ar number
1062 to the plex name.
1063 .\".Pp
1064 .\".It Xo
1065 .\".Ic replace
1066 .\".Ar drive newdrive
1067 .\"Move all the subdisks from the specified drive onto the new drive.  This will
1068 .\"attempt to recover those subdisks that can be recovered, and create the others
1069 .\"from scratch.  If the new drive lacks the space for this operation, as many
1070 .\"subdisks as possible will be fitted onto the drive, and the rest will be left on
1071 .\"the original drive.
1072 .Pp
1073 .It Ic resetconfig
1074 The
1075 .Ic resetconfig
1076 command completely obliterates the
1077 .Nm
1078 configuration on a system.  Use this command only when you want to completely
1079 delete the configuration.
1080 .Nm
1081 will ask for confirmation; you must type in the words
1082 .Li "NO FUTURE"
1083 exactly as shown:
1084 .Bd -unfilled -offset indent
1085 .No # Nm Ic resetconfig
1086
1087 WARNING!  This command will completely wipe out your vinum
1088 configuration.  All data will be lost.  If you really want
1089 to do this, enter the text
1090
1091 NO FUTURE
1092 .No "Enter text ->" Sy "NO FUTURE"
1093 Vinum configuration obliterated
1094 .Ed
1095 .Pp
1096 As the message suggests, this is a last-ditch command.  Don't use it unless you
1097 have an existing configuration which you never want to see again.
1098 .Pp
1099 .It Xo
1100 .Ic resetstats
1101 .Op Fl r
1102 .Op Ar volume | plex | subdisk
1103 .Xc
1104 .Nm
1105 maintains a number of statistical counters for each object.  See the header file
1106 .Aq Pa sys/dev/vinumvar.h
1107 for more information.
1108 .\" XXX put it in here when it's finalized
1109 Use the
1110 .Ic resetstats
1111 command to reset these counters.  In conjunction with the
1112 .Fl r
1113 option,
1114 .Nm
1115 also resets the counters of subordinate objects.
1116 .Pp
1117 .It Xo
1118 .Ic rm
1119 .Op Fl f
1120 .Op Fl r
1121 .Ar volume | plex | subdisk
1122 .Xc
1123 .Ic rm
1124 removes an object from the
1125 .Nm
1126 configuration.  Once an object has been removed, there is no way to recover it.
1127 Normally
1128 .Nm
1129 performs a large amount of consistency checking before removing an object.  The
1130 .Fl f
1131 option tells
1132 .Nm
1133 to omit this checking and remove the object anyway.  Use this option with great
1134 care: it can result in total loss of data on a volume.
1135 .Pp
1136 Normally,
1137 .Nm
1138 refuses to remove a volume or plex if it has subordinate plexes or subdisks
1139 respectively.  You can tell
1140 .Nm
1141 to remove the object anyway by using the
1142 .Fl f
1143 option, or you can cause
1144 .Nm
1145 to remove the subordinate objects as well by using the
1146 .Fl r
1147 (recursive) option.  If you remove a volume with the
1148 .Fl r
1149 option, it will remove both the plexes and the subdisks which belong to the
1150 plexes.
1151 .Pp
1152 .It Ic saveconfig
1153 Save the current configuration to disk.  Normally this is not necessary, since
1154 .Nm
1155 automatically saves any change in configuration.  If an error occurs on startup,
1156 updates will be disabled.  When you reenable them with the
1157 .Ic setdaemon
1158 command,
1159 .Nm
1160 does not automatically save the configuration to disk.  Use this command to save
1161 the configuration.
1162 .\".Pp
1163 .\".It Xo
1164 .\".Ic set
1165 .\".Op Fl f
1166 .\".Ar state
1167 .\".Ar volume | plex | subdisk | disk
1168 .\".Xc
1169 .\".Ic set
1170 .\"sets the state of the specified object to one of the valid states (see
1171 .\".Sx OBJECT STATES
1172 .\"below).  Normally
1173 .\".Nm
1174 .\"performs a large amount of consistency checking before making the change.  The
1175 .\".Fl f
1176 .\"option tells
1177 .\".Nm
1178 .\"to omit this checking and perform the change anyway.  Use this option with great
1179 .\"care: it can result in total loss of data on a volume.
1180 .Pp
1181 .It Ic setdaemon Op Ar value
1182 .Ic setdaemon
1183 sets a variable bitmask for the
1184 .Nm
1185 daemon.  This command is temporary and will be replaced.  Currently, the bit mask
1186 may contain the bits 1 (log every action to syslog) and 4 (don't update
1187 configuration).  Option bit 4 can be useful for error recovery.
1188 .Pp
1189 .It Xo
1190 .Ic setstate Ar state
1191 .Op Ar volume | plex | subdisk | drive
1192 .Xc
1193 .Ic setstate
1194 sets the state of the specified objects to the specified state.  This bypasses
1195 the usual consistency mechanism of
1196 .Nm
1197 and should be used only for recovery purposes.  It is possible to crash the
1198 system by incorrect use of this command.
1199 .Pp
1200 .It Xo
1201 .Ic start
1202 .Op Fl i Ar interval
1203 .Op Fl S Ar size
1204 .Op Fl w
1205 .Op Ar plex | subdisk
1206 .Xc
1207 .Ic start
1208 starts (brings into to the
1209 .Em up
1210 state) one or more
1211 .Nm
1212 objects.
1213 .Pp
1214 If no object names are specified,
1215 .Nm
1216 scans the disks known to the system for
1217 .Nm
1218 drives and then reads in the configuration as described under the
1219 .Ic read
1220 commands.  The
1221 .Nm
1222 drive contains a header with all information about the data stored on the drive,
1223 including the names of the other drives which are required in order to represent
1224 plexes and volumes.
1225 .Pp
1226 If
1227 .Nm
1228 encounters any errors during this command, it will turn off automatic
1229 configuration update to avoid corrupting the copies on disk.  This will also
1230 happen if the configuration on disk indicates a configuration error (for
1231 example, subdisks which do not have a valid space specification).  You can turn
1232 the updates on again with the
1233 .Ic setdaemon
1234 and
1235 .Ic saveconfig
1236 command.  Reset bit 4 of the daemon options mask to re-enable configuration
1237 saves.
1238 .Pp
1239 If object names are specified,
1240 .Nm
1241 starts them.  Normally this operation is only of use with subdisks.  The action
1242 depends on the current state of the object:
1243 .Bl -bullet
1244 .It
1245 If the object is already in the
1246 .Em up
1247 state,
1248 .Nm
1249 does nothing.
1250 .It
1251 If the object is a subdisk in the
1252 .Em down
1253 or
1254 .Em reborn
1255 states,
1256 .Nm
1257 changes it to the
1258 .Em up
1259 state.
1260 .It
1261 If the object is a subdisk in the
1262 .Em empty
1263 state, the change depends on the subdisk.  If it is part of a plex which is part
1264 of a volume which contains other plexes,
1265 .Nm
1266 places the subdisk in the
1267 .Em reviving
1268 state and attempts to copy the data from the volume.  When the operation
1269 completes, the subdisk is set into the
1270 .Em up
1271 state.  If it is part of a plex which is part of a volume which contains no
1272 other plexes, or if it is not part of a plex,
1273 .Nm
1274 brings it into the
1275 .Em up
1276 state immediately.
1277 .It
1278 If the object is a subdisk in the
1279 .Em reviving
1280 state,
1281 .Nm
1282 continues the revive
1283 operation offline.  When the operation completes, the subdisk is set into the
1284 .Em up
1285 state.
1286 .El
1287 .Pp
1288 When a subdisk comes into the
1289 .Em up
1290 state,
1291 .Nm
1292 automatically checks the state of any plex and volume to which it may belong and
1293 changes their state where appropriate.
1294 .Pp
1295 If the object is a plex,
1296 .Ic start
1297 checks the state of the subordinate subdisks (and plexes in the case of a
1298 volume) and starts any subdisks which can be started.
1299 .Pp
1300 To start a plex in a multi-plex volume, the data must be copied from another
1301 plex in the volume.  Since this frequently takes a long time, it is normally
1302 done in the background.  If you want to wait for this operation to complete (for
1303 example, if you are performing this operation in a script), use the
1304 .Fl w
1305 option.
1306 .Pp
1307 Copying data doesn't just take a long time, it can also place a significant load
1308 on the system.  You can specify the transfer size in bytes or sectors with the
1309 .Fl S
1310 option, and an interval (in milliseconds) to wait between copying each block with
1311 the
1312 .Fl i
1313 option.  Both of these options lessen the load on the system.
1314 .Pp
1315 .It Xo
1316 .Ic stop
1317 .Op Fl f
1318 .Op Ar volume | plex | subdisk
1319 .Xc
1320 If no parameters are specified,
1321 .Ic stop
1322 removes the
1323 .Nm
1324 kld and stops
1325 .Xr vinum 4 .
1326 This can only be done if no objects are active.  In particular, the
1327 .Fl f
1328 option does not override this requirement.  Normally, the
1329 .Ic stop
1330 command writes the current configuration back to the drives before terminating.
1331 This will not be possible if configuration updates are disabled, so
1332 .Nm
1333 will not stop if configuration updates are disabled.  You can override this by
1334 specifying the
1335 .Fl f
1336 option.
1337 .Pp
1338 The
1339 .Ic stop
1340 command can only work if
1341 .Nm
1342 has been loaded as a kld, since it is not possible to unload a statically
1343 configured driver.
1344 .Nm Ic stop
1345 will fail if
1346 .Nm
1347 is statically configured.
1348 .Pp
1349 If object names are specified,
1350 .Ic stop
1351 disables access to the objects.  If the objects have subordinate objects, the
1352 subordinate objects must either already be inactive (stopped or in error), or
1353 the
1354 .Fl r
1355 and
1356 .Fl f
1357 options must be specified.  This command does not remove the objects from the
1358 configuration.  They can be accessed again after a
1359 .Ic start
1360 command.
1361 .Pp
1362 By default,
1363 .Nm
1364 does not stop active objects.  For example, you cannot stop a plex which is
1365 attached to an active volume, and you cannot stop a volume which is open.  The
1366 .Fl f
1367 option tells
1368 .Nm
1369 to omit this checking and remove the object anyway.  Use this option with great
1370 care and understanding: used incorrectly, it can result in serious data
1371 corruption.
1372 .Pp
1373 .It Xo
1374 .Ic stripe
1375 .Op Fl f
1376 .Op Fl n Ar name
1377 .Op Fl v
1378 .Ar drives
1379 .Xc
1380 The
1381 .Ic stripe
1382 command provides a simplified alternative to the
1383 .Ic create
1384 command for creating volumes with a single striped plex.  The size of the
1385 subdisks is the size of the largest contiguous space available on all the
1386 specified drives.  The stripe size is fixed at 279 kB.
1387 .Pp
1388 Normally, the
1389 .Ic stripe
1390 command creates an arbitrary name for the volume and its components.  The name
1391 is composed of the text
1392 .Dq Li vinum
1393 and a small integer, for example
1394 .Dq Li vinum3 .
1395 You can override this with the
1396 .Fl n Ar name
1397 option, which assigns the name specified to the volume.  The plexes and subdisks
1398 are named after the volume in the default manner.
1399 .Pp
1400 There is no choice of name for the drives.  If the drives have already been
1401 initialized as
1402 .Nm
1403 drives, the name remains.  Otherwise the drives are given names starting with
1404 the text
1405 .Dq Li vinumdrive
1406 and a small integer, for example
1407 .Dq Li vinumdrive7 .
1408 As with the
1409 .Ic create
1410 command, the
1411 .Fl f
1412 option can be used to specify that a previous name should be overwritten.  The
1413 .Fl v
1414 is used to specify verbose output.
1415 .Pp
1416 See the section
1417 .Sx SIMPLIFIED CONFIGURATION
1418 below for some examples of this
1419 command.
1420 .El
1421 .Sh SIMPLIFIED CONFIGURATION
1422 This section describes a simplified interface to
1423 .Nm
1424 configuration using the
1425 .Ic concat ,
1426 .Ic mirror
1427 and
1428 .Ic stripe
1429 commands.  These commands create convenient configurations for some more normal
1430 situations, but they are not as flexible as the
1431 .Ic create
1432 command.
1433 .Pp
1434 See above for the description of the commands.  Here are some examples, all
1435 performed with the same collection of disks.  Note that the first drive,
1436 .Pa /dev/da1h ,
1437 is smaller than the others.  This has an effect on the sizes chosen for each
1438 kind of subdisk.
1439 .Pp
1440 The following examples all use the
1441 .Fl v
1442 option to show the commands passed to the system, and also to list the structure
1443 of the volume.  Without the
1444 .Fl v
1445 option, these commands produce no output.
1446 .Ss Volume with a single concatenated plex
1447 Use a volume with a single concatenated plex for the largest possible storage
1448 without resilience to drive failures:
1449 .Bd -literal
1450 vinum -> concat -v /dev/da1h /dev/da2h /dev/da3h /dev/da4h
1451 volume vinum0
1452   plex name vinum0.p0 org concat
1453 drive vinumdrive0 device /dev/da1h
1454     sd name vinum0.p0.s0 drive vinumdrive0 size 0
1455 drive vinumdrive1 device /dev/da2h
1456     sd name vinum0.p0.s1 drive vinumdrive1 size 0
1457 drive vinumdrive2 device /dev/da3h
1458     sd name vinum0.p0.s2 drive vinumdrive2 size 0
1459 drive vinumdrive3 device /dev/da4h
1460     sd name vinum0.p0.s3 drive vinumdrive3 size 0
1461 V vinum0                State: up       Plexes:       1 Size:       2134 MB
1462 P vinum0.p0           C State: up       Subdisks:     4 Size:       2134 MB
1463 S vinum0.p0.s0          State: up       D: vinumdrive0  Size:        414 MB
1464 S vinum0.p0.s1          State: up       D: vinumdrive1  Size:        573 MB
1465 S vinum0.p0.s2          State: up       D: vinumdrive2  Size:        573 MB
1466 S vinum0.p0.s3          State: up       D: vinumdrive3  Size:        573 MB
1467 .Ed
1468 .Pp
1469 In this case, the complete space on all four disks was used, giving a volume
1470 2134 MB in size.
1471 .Ss Volume with a single striped plex
1472 A volume with a single striped plex may give better performance than a
1473 concatenated plex, but restrictions on striped plexes can mean that the volume
1474 is smaller.  It will also not be resilient to a drive failure:
1475 .Bd -literal
1476 vinum -> stripe -v /dev/da1h /dev/da2h /dev/da3h /dev/da4h
1477 drive vinumdrive0 device /dev/da1h
1478 drive vinumdrive1 device /dev/da2h
1479 drive vinumdrive2 device /dev/da3h
1480 drive vinumdrive3 device /dev/da4h
1481 volume vinum0
1482   plex name vinum0.p0 org striped 279k
1483     sd name vinum0.p0.s0 drive vinumdrive0 size 849825b
1484     sd name vinum0.p0.s1 drive vinumdrive1 size 849825b
1485     sd name vinum0.p0.s2 drive vinumdrive2 size 849825b
1486     sd name vinum0.p0.s3 drive vinumdrive3 size 849825b
1487 V vinum0                State: up       Plexes:       1 Size:       1659 MB
1488 P vinum0.p0           S State: up       Subdisks:     4 Size:       1659 MB
1489 S vinum0.p0.s0          State: up       D: vinumdrive0  Size:        414 MB
1490 S vinum0.p0.s1          State: up       D: vinumdrive1  Size:        414 MB
1491 S vinum0.p0.s2          State: up       D: vinumdrive2  Size:        414 MB
1492 S vinum0.p0.s3          State: up       D: vinumdrive3  Size:        414 MB
1493 .Ed
1494 .Pp
1495 In this case, the size of the subdisks has been limited to the smallest
1496 available disk, so the resulting volume is only 1659 MB in size.
1497 .Ss Mirrored volume with two concatenated plexes
1498 For more reliability, use a mirrored, concatenated volume:
1499 .Bd -literal
1500 vinum -> mirror -v -n mirror /dev/da1h /dev/da2h /dev/da3h /dev/da4h
1501 drive vinumdrive0 device /dev/da1h
1502 drive vinumdrive1 device /dev/da2h
1503 drive vinumdrive2 device /dev/da3h
1504 drive vinumdrive3 device /dev/da4h
1505 volume mirror setupstate
1506   plex name mirror.p0 org concat
1507     sd name mirror.p0.s0 drive vinumdrive0 size 0b
1508     sd name mirror.p0.s1 drive vinumdrive2 size 0b
1509   plex name mirror.p1 org concat
1510     sd name mirror.p1.s0 drive vinumdrive1 size 0b
1511     sd name mirror.p1.s1 drive vinumdrive3 size 0b
1512 V mirror                State: up       Plexes:       2 Size:       1146 MB
1513 P mirror.p0           C State: up       Subdisks:     2 Size:        988 MB
1514 P mirror.p1           C State: up       Subdisks:     2 Size:       1146 MB
1515 S vinum0.p0.s0          State: up       D: vinumdrive0  Size:        414 MB
1516 S vinum0.p0.s2          State: up       D: vinumdrive2  Size:        414 MB
1517 S vinum0.p0.s1          State: up       D: vinumdrive1  Size:        414 MB
1518 S vinum0.p0.s3          State: up       D: vinumdrive3  Size:        414 MB
1519 .Ed
1520 .Pp
1521 This example specifies the name of the volume,
1522 .Ar mirror .
1523 Since one drive is smaller than the others, the two plexes are of different
1524 size, and the last 158 MB of the volume is non-resilient.  To ensure complete
1525 reliability in such a situation, use the
1526 .Ic create
1527 command to create a volume with 988 MB.
1528 .Ss Mirrored volume with two striped plexes
1529 Alternatively, use the
1530 .Fl s
1531 option to create a mirrored volume with two striped plexes:
1532 .Bd -literal
1533 vinum -> mirror -v -n raid10 -s /dev/da1h /dev/da2h /dev/da3h /dev/da4h
1534 drive vinumdrive0 device /dev/da1h
1535 drive vinumdrive1 device /dev/da2h
1536 drive vinumdrive2 device /dev/da3h
1537 drive vinumdrive3 device /dev/da4h
1538 volume raid10 setupstate
1539   plex name raid10.p0 org striped 279k
1540     sd name raid10.p0.s0 drive vinumdrive0 size 849825b
1541     sd name raid10.p0.s1 drive vinumdrive2 size 849825b
1542   plex name raid10.p1 org striped 279k
1543     sd name raid10.p1.s0 drive vinumdrive1 size 1173665b
1544     sd name raid10.p1.s1 drive vinumdrive3 size 1173665b
1545 V raid10                State: up       Plexes:       2 Size:       1146 MB
1546 P raid10.p0           S State: up       Subdisks:     2 Size:        829 MB
1547 P raid10.p1           S State: up       Subdisks:     2 Size:       1146 MB
1548 S raid10.p0.s0          State: up       PO:        0  B Size:        414 MB
1549 S raid10.p0.s1          State: up       PO:      279 kB Size:        414 MB
1550 S raid10.p1.s0          State: up       PO:        0  B Size:        573 MB
1551 S raid10.p1.s1          State: up       PO:      279 kB Size:        573 MB
1552 .Ed
1553 .Pp
1554 In this case, the usable part of the volume is even smaller, since the first
1555 plex has shrunken to match the smallest drive.
1556 .Sh CONFIGURATION FILE
1557 .Nm
1558 requires that all parameters to the
1559 .Ic create
1560 commands must be in a configuration file.  Entries in the configuration file
1561 define volumes, plexes and subdisks, and may be in free format, except that each
1562 entry must be on a single line.
1563 .Ss Scale factors
1564 Some configuration file parameters specify a size (lengths, stripe sizes).
1565 These values can be specified as bytes, or one of the following scale factors
1566 may be appended:
1567 .Bl -tag -width indent
1568 .It s
1569 specifies that the value is a number of sectors of 512 bytes.
1570 .It k
1571 specifies that the value is a number of kilobytes (1024 bytes).
1572 .It m
1573 specifies that the value is a number of megabytes (1048576 bytes).
1574 .It g
1575 specifies that the value is a number of gigabytes (1073741824 bytes).
1576 .It b
1577 is used for compatibility with
1578 .Tn VERITAS .
1579 It stands for blocks of 512 bytes.
1580 This abbreviation is confusing, since the word
1581 .Dq block
1582 is used in different meanings, and its use is deprecated.  Use the keyword 's'
1583 instead.
1584 .El
1585 .Pp
1586 For example, the value 16777216 bytes can also be written as
1587 .Em 16m ,
1588 .Em 16384k
1589 or
1590 .Em 32768s .
1591 .Pp
1592 The configuration file can contain the following entries:
1593 .Bl -tag -width 4n
1594 .It Ic drive Ar name devicename Op Ar options
1595 Define a drive.  The options are:
1596 .Bl -tag -width 18n
1597 .It Cm device Ar devicename
1598 Specify the device on which the drive resides.
1599 .Ar devicename
1600 must be the name of a disk partition, for example
1601 .Pa /dev/da1e
1602 or
1603 .Pa /dev/ad3s2h ,
1604 and it must be of type
1605 .Em vinum .
1606 Do not use the
1607 .Dq Li c
1608 partition, which is reserved for the complete disk.
1609 .It Cm hotspare
1610 Define the drive to be a
1611 .Dq hot spare
1612 drive, which is maintained to automatically replace a failed drive.
1613 .Nm
1614 does not allow this drive to be used for any other purpose.  In particular, it
1615 is not possible to create subdisks on it.  This functionality has not been
1616 completely implemented.
1617 .El
1618 .It Ic volume Ar name Op Ar options
1619 Define a volume with name
1620 .Ar name .
1621 Options are:
1622 .Bl -tag -width 18n
1623 .It Cm plex Ar plexname
1624 Add the specified plex to the volume.  If
1625 .Ar plexname
1626 is specified as
1627 .Cm * ,
1628 .Nm
1629 will look for the definition of the plex as the next possible entry in the
1630 configuration file after the definition of the volume.
1631 .It Cm readpol Ar policy
1632 Define a
1633 .Em read policy
1634 for the volume.
1635 .Ar policy
1636 may be either
1637 .Cm round
1638 or
1639 .Cm prefer Ar plexname .
1640 .Nm
1641 satisfies a read request from only one of the plexes.  A
1642 .Cm round
1643 read policy specifies that each read should be performed from a different plex
1644 in
1645 .Em round-robin
1646 fashion.  A
1647 .Cm prefer
1648 read policy reads from the specified plex every time.
1649 .It Cm setupstate
1650 When creating a multi-plex volume, assume that the contents of all the plexes
1651 are consistent.  This is normally not the case, so by default
1652 .Nm
1653 sets all plexes except the first one to the
1654 .Em faulty
1655 state.  Use the
1656 .Ic start
1657 command to first bring them to a consistent state.  In the case of striped and
1658 concatenated plexes, however, it does not normally cause problems to leave them
1659 inconsistent: when using a volume for a file system or a swap partition, the
1660 previous contents of the disks are not of interest, so they may be ignored.
1661 If you want to take this risk, use the
1662 .Cm setupstate
1663 keyword.  It will only apply to the plexes defined immediately after the volume
1664 in the configuration file.  If you add plexes to a volume at a later time, you
1665 must integrate them manually with the
1666 .Ic start
1667 command.
1668 .Pp
1669 Note that you
1670 .Em must
1671 use the
1672 .Ic init
1673 command with RAID-5 plexes: otherwise extreme data corruption will result if one
1674 subdisk fails.
1675 .El
1676 .It Ic plex Op Ar options
1677 Define a plex.  Unlike a volume, you do not need to specify a name for a plex.
1678 The options may be:
1679 .Bl -tag -width 18n
1680 .It Cm name Ar plexname
1681 Specify the name of the plex.  Note that you must use the keyword
1682 .Cm name
1683 when naming a plex or subdisk.
1684 .It Cm org Ar organization Op Ar stripesize
1685 Specify the organization of the plex.
1686 .Ar organization
1687 can be one of
1688 .Cm concat , striped
1689 or
1690 .Cm raid5 .
1691 For
1692 .Cm striped
1693 and
1694 .Cm raid5
1695 plexes, the parameter
1696 .Ar stripesize
1697 must be specified, while for
1698 .Cm concat
1699 it must be omitted.  For type
1700 .Cm striped ,
1701 it specifies the width of each stripe.  For type
1702 .Cm raid5 ,
1703 it specifies the size of a group.  A group is a portion of a plex which
1704 stores the parity bits all in the same subdisk.  It must be a factor of the plex size (in
1705 other words, the result of dividing the plex size by the stripe size must be an
1706 integer), and it must be a multiple of a disk sector (512 bytes).
1707 .Pp
1708 For optimum performance, stripes should be at least 128 kB in size: anything
1709 smaller will result in a significant increase in I/O activity due to mapping of
1710 individual requests over multiple disks.  The performance improvement due to the
1711 increased number of concurrent transfers caused by this mapping will not make up
1712 for the performance drop due to the increase in latency.  A good guideline for
1713 stripe size is between 256 kB and 512 kB.  Avoid powers of 2, however: they tend
1714 to cause all superblocks to be placed on the first subdisk.  The simplified
1715 commands use a stripe size of 279 kB, which shows a reasonable distribution of
1716 superblocks.
1717 .Pp
1718 A striped plex must have at least two subdisks (otherwise it is a concatenated
1719 plex), and each must be the same size.  A RAID-5 plex must have at least three
1720 subdisks, and each must be the same size.  In practice, a RAID-5 plex should
1721 have at least 5 subdisks.
1722 .It Cm volume Ar volname
1723 Add the plex to the specified volume.  If no
1724 .Cm volume
1725 keyword is specified, the plex will be added to the last volume mentioned in the
1726 configuration file.
1727 .It Cm sd Ar sdname offset
1728 Add the specified subdisk to the plex at offset
1729 .Ar offset .
1730 .El
1731 .It Ic subdisk Op Ar options
1732 Define a subdisk.  Options may be:
1733 .Bl -hang -width 18n
1734 .It Cm name Ar name
1735 Specify the name of a subdisk.  It is not necessary to specify a name for a
1736 subdisk\(emsee
1737 .Sx OBJECT NAMING
1738 above.  Note that you must specify the keyword
1739 .Cm name
1740 if you wish to name a subdisk.
1741 .It Cm plexoffset Ar offset
1742 Specify the starting offset of the subdisk in the plex.  If not specified,
1743 .Nm
1744 allocates the space immediately after the previous subdisk, if any, or otherwise
1745 at the beginning of the plex.
1746 .It Cm driveoffset Ar offset
1747 Specify the starting offset of the subdisk in the drive.  If not specified,
1748 .Nm
1749 allocates the first contiguous
1750 .Ar length
1751 bytes of free space on the drive.
1752 .It Cm length Ar length
1753 Specify the length of the subdisk.  This keyword must be specified.  There is no
1754 default, but the value 0 may be specified to mean
1755 .Dq "use the largest available contiguous free area on the drive" .
1756 If the drive is empty, this means that the entire drive will be used for the
1757 subdisk.
1758 .Cm length
1759 may be shortened to
1760 .Cm len .
1761 .It Cm plex Ar plex
1762 Specify the plex to which the subdisk belongs.  By default, the subdisk belongs
1763 to the last plex specified.
1764 .It Cm drive Ar drive
1765 Specify the drive on which the subdisk resides.  By default, the subdisk resides
1766 on the last drive specified.
1767 .It Cm retryerrors
1768 Specify that the subdisk should not be taken down if an unrecoverable error
1769 occurs.  Normally
1770 .Nm
1771 responds to an unrecoverable error by making the entire subdisk inaccessible.
1772 .El
1773 .El
1774 .Sh EXAMPLE CONFIGURATION FILE
1775 .Bd -literal
1776 # Sample vinum configuration file
1777 #
1778 # Our drives
1779 drive drive1 device /dev/da1h
1780 drive drive2 device /dev/da2h
1781 drive drive3 device /dev/da3h
1782 drive drive4 device /dev/da4h
1783 drive drive5 device /dev/da5h
1784 drive drive6 device /dev/da6h
1785 # A volume with one striped plex
1786 volume tinyvol
1787  plex org striped 279k
1788   sd length 64m drive drive2
1789   sd length 64m drive drive4
1790 volume stripe
1791  plex org striped 279k
1792   sd length 512m drive drive2
1793   sd length 512m drive drive4
1794 # Two plexes
1795 volume concat
1796  plex org concat
1797   sd length 100m drive drive2
1798   sd length 50m drive drive4
1799  plex org concat
1800   sd length 150m drive drive4
1801 # A volume with one striped plex and one concatenated plex
1802 volume strcon
1803  plex org striped 279k
1804   sd length 100m drive drive2
1805   sd length 100m drive drive4
1806  plex org concat
1807   sd length 150m drive drive2
1808   sd length 50m drive drive4
1809 # a volume with a RAID-5 and a striped plex
1810 # note that the RAID-5 volume is longer by
1811 # the length of one subdisk
1812 volume vol5
1813  plex org striped 491k
1814   sd length 1000m drive drive2
1815   sd length 1000m drive drive4
1816  plex org raid5 273k
1817   sd length 500m drive drive1
1818   sd length 500m drive drive2
1819   sd length 500m drive drive3
1820   sd length 500m drive drive4
1821   sd length 500m drive drive5
1822 .Ed
1823 .Sh DRIVE LAYOUT CONSIDERATIONS
1824 .Nm
1825 drives are currently
1826 .Bx
1827 disk partitions.  They must be of type
1828 .Em vinum
1829 in order to avoid overwriting data used for other purposes.  Use
1830 .Nm disklabel Fl e
1831 to edit a partition type definition.  The following display shows a typical
1832 partition layout as shown by
1833 .Xr disklabel 8 :
1834 .Bd -literal
1835 8 partitions:
1836 #        size   offset    fstype   [fsize bsize bps/cpg]
1837   a:    81920   344064    4.2BSD        0     0     0   # (Cyl.  240*- 297*)
1838   b:   262144    81920      swap                        # (Cyl.   57*- 240*)
1839   c:  4226725        0    unused        0     0         # (Cyl.    0 - 2955*)
1840   e:    81920        0    4.2BSD        0     0     0   # (Cyl.    0 - 57*)
1841   f:  1900000   425984    4.2BSD        0     0     0   # (Cyl.  297*- 1626*)
1842   g:  1900741  2325984     vinum        0     0     0   # (Cyl. 1626*- 2955*)
1843 .Ed
1844 .Pp
1845 In this example, partition
1846 .Dq Li g
1847 may be used as a
1848 .Nm
1849 partition.  Partitions
1850 .Dq Li a ,
1851 .Dq Li e
1852 and
1853 .Dq Li f
1854 may be used as
1855 .Em UFS
1856 file systems or
1857 .Em ccd
1858 partitions.  Partition
1859 .Dq Li b
1860 is a swap partition, and partition
1861 .Dq Li c
1862 represents the whole disk and should not be used for any other purpose.
1863 .Pp
1864 .Nm
1865 uses the first 265 sectors on each partition for configuration information, so
1866 the maximum size of a subdisk is 265 sectors smaller than the drive.
1867 .Sh LOG FILE
1868 .Nm
1869 maintains a log file, by default
1870 .Pa /var/tmp/vinum_history ,
1871 in which it keeps track of the commands issued to
1872 .Nm .
1873 You can override the name of this file by setting the environment variable
1874 .Ev VINUM_HISTORY
1875 to the name of the file.
1876 .Pp
1877 Each message in the log file is preceded by a date.  The default format is
1878 .Qq Li %e %b %Y %H:%M:%S .
1879 See
1880 .Xr strftime 3
1881 for further details of the format string.  It can be overridden by the
1882 environment variable
1883 .Ev VINUM_DATEFORMAT .
1884 .Sh HOW TO SET UP VINUM
1885 This section gives practical advice about how to implement a
1886 .Nm
1887 system.
1888 .Ss Where to put the data
1889 The first choice you need to make is where to put the data.  You need dedicated
1890 disk partitions for
1891 .Nm .
1892 They should be partitions, not devices, and they should not be partition
1893 .Dq Li c .
1894 For example, good names are
1895 .Pa /dev/da0e
1896 or
1897 .Pa /dev/ad3s4a .
1898 Bad names are
1899 .Pa /dev/da0
1900 and
1901 .Pa /dev/da0s1 ,
1902 both of which represent a device, not a partition, and
1903 .Pa /dev/ad1c ,
1904 which represents a complete disk and should be of type
1905 .Em unused .
1906 See the example under
1907 .Sx DRIVE LAYOUT CONSIDERATIONS
1908 above.
1909 .Ss Designing volumes
1910 The way you set up
1911 .Nm
1912 volumes depends on your intentions.  There are a number of possibilities:
1913 .Bl -enum
1914 .It
1915 You may want to join up a number of small disks to make a reasonable sized file
1916 system.  For example, if you had five small drives and wanted to use all the
1917 space for a single volume, you might write a configuration file like:
1918 .Bd -literal -offset indent
1919 drive d1 device /dev/da2e
1920 drive d2 device /dev/da3e
1921 drive d3 device /dev/da4e
1922 drive d4 device /dev/da5e
1923 drive d5 device /dev/da6e
1924 volume bigger
1925  plex org concat
1926    sd length 0 drive d1
1927    sd length 0 drive d2
1928    sd length 0 drive d3
1929    sd length 0 drive d4
1930    sd length 0 drive d5
1931 .Ed
1932 .Pp
1933 In this case, you specify the length of the subdisks as 0, which means
1934 .Dq "use the largest area of free space that you can find on the drive" .
1935 If the subdisk is the only subdisk on the drive, it will use all available
1936 space.
1937 .It
1938 You want to set up
1939 .Nm
1940 to obtain additional resilience against disk failures.  You have the choice of
1941 RAID-1, also called
1942 .Dq mirroring ,
1943 or RAID-5, also called
1944 .Dq parity .
1945 .Pp
1946 To set up mirroring, create multiple plexes in a volume.  For example, to create
1947 a mirrored volume of 2 GB, you might create the following configuration file:
1948 .Bd -literal -offset indent
1949 drive d1 device /dev/da2e
1950 drive d2 device /dev/da3e
1951 volume mirror
1952  plex org concat
1953    sd length 2g drive d1
1954  plex org concat
1955    sd length 2g drive d2
1956 .Ed
1957 .Pp
1958 When creating mirrored drives, it is important to ensure that the data from each
1959 plex is on a different physical disk so that
1960 .Nm
1961 can access the complete address space of the volume even if a drive fails.
1962 Note that each plex requires as much data as the complete volume: in this
1963 example, the volume has a size of 2 GB, but each plex (and each subdisk)
1964 requires 2 GB, so the total disk storage requirement is 4 GB.
1965 .Pp
1966 To set up RAID-5, create a single plex of type
1967 .Cm raid5 .
1968 For example, to create an equivalent resilient volume of 2 GB, you might use the
1969 following configuration file:
1970 .Bd -literal -offset indent
1971 drive d1 device /dev/da2e
1972 drive d2 device /dev/da3e
1973 drive d3 device /dev/da4e
1974 drive d4 device /dev/da5e
1975 drive d5 device /dev/da6e
1976 volume raid
1977  plex org raid5 433k
1978    sd length 512m drive d1
1979    sd length 512m drive d2
1980    sd length 512m drive d3
1981    sd length 512m drive d4
1982    sd length 512m drive d5
1983 .Ed
1984 .Pp
1985 RAID-5 plexes require at least three subdisks, one of which is used for storing
1986 parity information and is lost for data storage.  The more disks you use, the
1987 greater the proportion of the disk storage can be used for data storage.  In
1988 this example, the total storage usage is 2.5 GB, compared to 4 GB for a mirrored
1989 configuration.  If you were to use the minimum of only three disks, you would
1990 require 3 GB to store the information, for example:
1991 .Bd -literal -offset indent
1992 drive d1 device /dev/da2e
1993 drive d2 device /dev/da3e
1994 drive d3 device /dev/da4e
1995 volume raid
1996  plex org raid5 433k
1997    sd length 1g drive d1
1998    sd length 1g drive d2
1999    sd length 1g drive d3
2000 .Ed
2001 .Pp
2002 As with creating mirrored drives, it is important to ensure that the data from
2003 each subdisk is on a different physical disk so that
2004 .Nm
2005 can access the complete address space of the volume even if a drive fails.
2006 .It
2007 You want to set up
2008 .Nm
2009 to allow more concurrent access to a file system.  In many cases, access to a
2010 file system is limited by the speed of the disk.  By spreading the volume across
2011 multiple disks, you can increase the throughput in multi-access environments.
2012 This technique shows little or no performance improvement in single-access
2013 environments.
2014 .Nm
2015 uses a technique called
2016 .Dq striping ,
2017 or sometimes RAID-0, to increase this concurrency of access.  The name RAID-0 is
2018 misleading: striping does not provide any redundancy or additional reliability.
2019 In fact, it decreases the reliability, since the failure of a single disk will
2020 render the volume useless, and the more disks you have, the more likely it is
2021 that one of them will fail.
2022 .Pp
2023 To implement striping, use a
2024 .Cm striped
2025 plex:
2026 .Bd -literal -offset indent
2027 drive d1 device /dev/da2e
2028 drive d2 device /dev/da3e
2029 drive d3 device /dev/da4e
2030 drive d4 device /dev/da5e
2031 volume raid
2032  plex org striped 433k
2033    sd length 512m drive d1
2034    sd length 512m drive d2
2035    sd length 512m drive d3
2036    sd length 512m drive d4
2037 .Ed
2038 .Pp
2039 A striped plex must have at least two subdisks, but the increase in performance
2040 is greater if you have a larger number of disks.
2041 .It
2042 You may want to have the best of both worlds and have both resilience and
2043 performance.  This is sometimes called RAID-10 (a combination of RAID-1 and
2044 RAID-0), though again this name is misleading.  With
2045 .Nm
2046 you can do this with the following configuration file:
2047 .Bd -literal -offset indent
2048 drive d1 device /dev/da2e
2049 drive d2 device /dev/da3e
2050 drive d3 device /dev/da4e
2051 drive d4 device /dev/da5e
2052 volume raid setupstate
2053  plex org striped 433k
2054    sd length 512m drive d1
2055    sd length 512m drive d2
2056    sd length 512m drive d3
2057    sd length 512m drive d4
2058  plex org striped 433k
2059    sd length 512m drive d4
2060    sd length 512m drive d3
2061    sd length 512m drive d2
2062    sd length 512m drive d1
2063 .Ed
2064 .Pp
2065 Here the plexes are striped, increasing performance, and there are two of them,
2066 increasing reliablity.  Note that this example shows the subdisks of the second
2067 plex in reverse order from the first plex.  This is for performance reasons and
2068 will be discussed below.  In addition, the volume specification includes the
2069 keyword
2070 .Cm setupstate ,
2071 which ensures that all plexes are
2072 .Em up
2073 after creation.
2074 .El
2075 .Ss Creating the volumes
2076 Once you have created your configuration files, start
2077 .Nm
2078 and create the volumes.  In this example, the configuration is in the file
2079 .Pa configfile :
2080 .Bd -literal -offset 2n
2081 # vinum create -v configfile
2082    1: drive d1 device /dev/da2e
2083    2: drive d2 device /dev/da3e
2084    3: volume mirror
2085    4:  plex org concat
2086    5:    sd length 2g drive d1
2087    6:  plex org concat
2088    7:    sd length 2g drive d2
2089 Configuration summary
2090
2091 Drives:         2 (4 configured)
2092 Volumes:        1 (4 configured)
2093 Plexes:         2 (8 configured)
2094 Subdisks:       2 (16 configured)
2095
2096 Drive d1:       Device /dev/da2e
2097                 Created on vinum.lemis.com at Tue Mar 23 12:30:31 1999
2098                 Config last updated Tue Mar 23 14:30:32 1999
2099                 Size:      60105216000 bytes (57320 MB)
2100                 Used:       2147619328 bytes (2048 MB)
2101                 Available: 57957596672 bytes (55272 MB)
2102                 State: up
2103                 Last error: none
2104 Drive d2:       Device /dev/da3e
2105                 Created on vinum.lemis.com at Tue Mar 23 12:30:32 1999
2106                 Config last updated Tue Mar 23 14:30:33 1999
2107                 Size:      60105216000 bytes (57320 MB)
2108                 Used:       2147619328 bytes (2048 MB)
2109                 Available: 57957596672 bytes (55272 MB)
2110                 State: up
2111                 Last error: none
2112
2113 Volume mirror:  Size: 2147483648 bytes (2048 MB)
2114                 State: up
2115                 Flags:
2116                 2 plexes
2117                 Read policy: round robin
2118
2119 Plex mirror.p0: Size:   2147483648 bytes (2048 MB)
2120                 Subdisks:        1
2121                 State: up
2122                 Organization: concat
2123                 Part of volume mirror
2124 Plex mirror.p1: Size:   2147483648 bytes (2048 MB)
2125                 Subdisks:        1
2126                 State: up
2127                 Organization: concat
2128                 Part of volume mirror
2129
2130 Subdisk mirror.p0.s0:
2131                 Size:       2147483648 bytes (2048 MB)
2132                 State: up
2133                 Plex mirror.p0 at offset 0
2134
2135 Subdisk mirror.p1.s0:
2136                 Size:       2147483648 bytes (2048 MB)
2137                 State: up
2138                 Plex mirror.p1 at offset 0
2139 .Ed
2140 .Pp
2141 The
2142 .Fl v
2143 option tells
2144 .Nm
2145 to list the file as it configures.  Subsequently it lists the current
2146 configuration in the same format as the
2147 .Ic list Fl v
2148 command.
2149 .Ss Creating more volumes
2150 Once you have created the
2151 .Nm
2152 volumes,
2153 .Nm
2154 keeps track of them in its internal configuration files.  You do not need to
2155 create them again.  In particular, if you run the
2156 .Ic create
2157 command again, you will create additional objects:
2158 .Bd -literal
2159 # vinum create sampleconfig
2160 Configuration summary
2161
2162 Drives:         2 (4 configured)
2163 Volumes:        1 (4 configured)
2164 Plexes:         4 (8 configured)
2165 Subdisks:       4 (16 configured)
2166
2167 D d1                    State: up       Device /dev/da2e        Avail: 53224/57320 MB (92%)
2168 D d2                    State: up       Device /dev/da3e        Avail: 53224/57320 MB (92%)
2169
2170 V mirror                State: up       Plexes:       4 Size:       2048 MB
2171
2172 P mirror.p0           C State: up       Subdisks:     1 Size:       2048 MB
2173 P mirror.p1           C State: up       Subdisks:     1 Size:       2048 MB
2174 P mirror.p2           C State: up       Subdisks:     1 Size:       2048 MB
2175 P mirror.p3           C State: up       Subdisks:     1 Size:       2048 MB
2176
2177 S mirror.p0.s0          State: up       PO:        0  B Size:       2048 MB
2178 S mirror.p1.s0          State: up       PO:        0  B Size:       2048 MB
2179 S mirror.p2.s0          State: up       PO:        0  B Size:       2048 MB
2180 S mirror.p3.s0          State: up       PO:        0  B Size:       2048 MB
2181 .Ed
2182 .Pp
2183 As this example (this time with the
2184 .Fl f
2185 option) shows, re-running the
2186 .Ic create
2187 has created four new plexes, each with a new subdisk.  If you want to add other
2188 volumes, create new configuration files for them.  They do not need to reference
2189 the drives that
2190 .Nm
2191 already knows about.  For example, to create a volume
2192 .Pa raid
2193 on the four drives
2194 .Pa /dev/da1e , /dev/da2e , /dev/da3e
2195 and
2196 .Pa /dev/da4e ,
2197 you only need to mention the other two:
2198 .Bd -literal -offset indent
2199 drive d3 device /dev/da1e
2200 drive d4 device /dev/da4e
2201 volume raid
2202   plex org raid5 433k
2203     sd size 2g drive d1
2204     sd size 2g drive d2
2205     sd size 2g drive d3
2206     sd size 2g drive d4
2207 .Ed
2208 .Pp
2209 With this configuration file, we get:
2210 .Bd -literal
2211 # vinum create newconfig
2212 Configuration summary
2213
2214 Drives:         4 (4 configured)
2215 Volumes:        2 (4 configured)
2216 Plexes:         5 (8 configured)
2217 Subdisks:       8 (16 configured)
2218
2219 D d1                    State: up       Device /dev/da2e        Avail: 51176/57320 MB (89%)
2220 D d2                    State: up       Device /dev/da3e        Avail: 53220/57320 MB (89%)
2221 D d3                    State: up       Device /dev/da1e        Avail: 53224/57320 MB (92%)
2222 D d4                    State: up       Device /dev/da4e        Avail: 53224/57320 MB (92%)
2223
2224 V mirror                State: down     Plexes:       4 Size:       2048 MB
2225 V raid                  State: down     Plexes:       1 Size:       6144 MB
2226
2227 P mirror.p0           C State: init     Subdisks:     1 Size:       2048 MB
2228 P mirror.p1           C State: init     Subdisks:     1 Size:       2048 MB
2229 P mirror.p2           C State: init     Subdisks:     1 Size:       2048 MB
2230 P mirror.p3           C State: init     Subdisks:     1 Size:       2048 MB
2231 P raid.p0            R5 State: init     Subdisks:     4 Size:       6144 MB
2232
2233 S mirror.p0.s0          State: up       PO:        0  B Size:       2048 MB
2234 S mirror.p1.s0          State: up       PO:        0  B Size:       2048 MB
2235 S mirror.p2.s0          State: up       PO:        0  B Size:       2048 MB
2236 S mirror.p3.s0          State: up       PO:        0  B Size:       2048 MB
2237 S raid.p0.s0            State: empty    PO:        0  B Size:       2048 MB
2238 S raid.p0.s1            State: empty    PO:      433 kB Size:       2048 MB
2239 S raid.p0.s2            State: empty    PO:      866 kB Size:       2048 MB
2240 S raid.p0.s3            State: empty    PO:     1299 kB Size:       2048 MB
2241 .Ed
2242 .Pp
2243 Note the size of the RAID-5 plex: it is only 6 GB, although together its
2244 components use 8 GB of disk space.  This is because the equivalent of one
2245 subdisk is used for storing parity data.
2246 .Ss Restarting Vinum
2247 On rebooting the system, start
2248 .Nm
2249 with the
2250 .Ic start
2251 command:
2252 .Pp
2253 .Dl "# vinum start"
2254 .Pp
2255 This will start all the
2256 .Nm
2257 drives in the system.  If for some reason you wish to start only some of them,
2258 use the
2259 .Ic read
2260 command.
2261 .Ss Performance considerations
2262 A number of misconceptions exist about how to set up a RAID array for best
2263 performance.  In particular, most systems use far too small a stripe size.  The
2264 following discussion applies to all RAID systems, not just to
2265 .Nm .
2266 .Pp
2267 The
2268 .Fx
2269 block I/O system issues requests of between .5kB and 128 kB; a
2270 typical mix is somewhere round 8 kB.  You can't stop any striping system from
2271 breaking a request into two physical requests, and if you make the stripe small
2272 enough, it can be broken into several.  This will result in a significant drop
2273 in performance: the decrease in transfer time per disk is offset by the order of
2274 magnitude greater increase in latency.
2275 .Pp
2276 With modern disk sizes and the
2277 .Fx
2278 I/O system, you can expect to have a
2279 reasonably small number of fragmented requests with a stripe size between 256 kB
2280 and 512 kB; with correct RAID implementations there is no obvious reason not to
2281 increase the size to 2 or 4 MB on a large disk.
2282 .Pp
2283 When choosing a stripe size, consider that most current UFS file systems have
2284 cylinder groups 32 MB in size.  If you have a stripe size and number of disks
2285 both of which are a power of two, it is probable that all superblocks and inodes
2286 will be placed on the same subdisk, which will impact performance significantly.
2287 Choose an odd number instead, for example 479 kB.
2288 .Pp
2289 The easiest way to consider the impact of any transfer in a multi-access system
2290 is to look at it from the point of view of the potential bottleneck, the disk
2291 subsystem: how much total disk time does the transfer use?
2292 Since just about
2293 everything is cached, the time relationship between the request and its
2294 completion is not so important: the important parameter is the total time that
2295 the request keeps the disks active, the time when the disks are not available to
2296 perform other transfers.  As a result, it doesn't really matter if the transfers
2297 are happening at the same time or different times.  In practical terms, the time
2298 we're looking at is the sum of the total latency (positioning time and
2299 rotational latency, or the time it takes for the data to arrive under the disk
2300 heads) and the total transfer time.  For a given transfer to disks of the same
2301 speed, the transfer time depends only on the total size of the transfer.
2302 .Pp
2303 Consider a typical news article or web page of 24 kB, which will probably be
2304 read in a single I/O.  Take disks with a transfer rate of 6 MB/s and an average
2305 positioning time of 8 ms, and a file system with 4 kB blocks.  Since it's 24 kB,
2306 we don't have to worry about fragments, so the file will start on a 4 kB
2307 boundary.  The number of transfers required depends on where the block starts:
2308 it's (S + F - 1) / S, where S is the stripe size in file system blocks, and F is
2309 the file size in file system blocks.
2310 .Bl -enum
2311 .It
2312 Stripe size of 4 kB.  You'll have 6 transfers.  Total subsystem load: 48 ms
2313 latency, 2 ms transfer, 50 ms total.
2314 .It
2315 Stripe size of 8 kB.  On average, you'll have 3.5 transfers.  Total subsystem
2316 load: 28 ms latency, 2 ms transfer, 30 ms total.
2317 .It
2318 Stripe size of 16 kB.  On average, you'll have 2.25 transfers.  Total subsystem
2319 load: 18 ms latency, 2 ms transfer, 20 ms total.
2320 .It
2321 Stripe size of 256 kB.  On average, you'll have 1.08 transfers.  Total subsystem
2322 load: 8.6 ms latency, 2 ms transfer, 10.6 ms total.
2323 .It
2324 Stripe size of 4 MB.  On average, you'll have 1.0009 transfers.  Total subsystem
2325 load: 8.01 ms latency, 2 ms transfer, 10.01 ms total.
2326 .El
2327 .Pp
2328 It appears that some hardware RAID systems have problems with large stripes:
2329 they appear to always transfer a complete stripe to or from disk, so that a
2330 large stripe size will have an adverse effect on performance.
2331 .Nm
2332 does not suffer from this problem: it optimizes all disk transfers and does not
2333 transfer unneeded data.
2334 .Pp
2335 Note that no well-known benchmark program tests true multi-access conditions
2336 (more than 100 concurrent users), so it is difficult to demonstrate the validity
2337 of these statements.
2338 .Pp
2339 Given these considerations, the following factors affect the performance of a
2340 .Nm
2341 volume:
2342 .Bl -bullet
2343 .It
2344 Striping improves performance for multiple access only, since it increases the
2345 chance of individual requests being on different drives.
2346 .It
2347 Concatenating UFS file systems across multiple drives can also improve
2348 performance for multiple file access, since UFS divides a file system into
2349 cylinder groups and attempts to keep files in a single cylinder group.  In
2350 general, it is not as effective as striping.
2351 .It
2352 Mirroring can improve multi-access performance for reads, since by default
2353 .Nm
2354 issues consecutive reads to consecutive plexes.
2355 .It
2356 Mirroring decreases performance for all writes, whether multi-access or single
2357 access, since the data must be written to both plexes.  This explains the
2358 subdisk layout in the example of a mirroring configuration above: if the
2359 corresponding subdisk in each plex is on a different physical disk, the write
2360 commands can be issued in parallel, whereas if they are on the same physical
2361 disk, they will be performed sequentially.
2362 .It
2363 RAID-5 reads have essentially the same considerations as striped reads, unless
2364 the striped plex is part of a mirrored volume, in which case the performance of
2365 the mirrored volume will be better.
2366 .It
2367 RAID-5 writes are approximately 25% of the speed of striped writes: to perform
2368 the write,
2369 .Nm
2370 must first read the data block and the corresponding parity block, perform some
2371 calculations and write back the parity block and the data block, four times as
2372 many transfers as for writing a striped plex.  On the other hand, this is offset
2373 by the cost of mirroring, so writes to a volume with a single RAID-5 plex are
2374 approximately half the speed of writes to a correctly configured volume with two
2375 striped plexes.
2376 .It
2377 When the
2378 .Nm
2379 configuration changes (for example, adding or removing objects, or the change of
2380 state of one of the objects),
2381 .Nm
2382 writes up to 128 kB of updated configuration to each drive.  The larger the
2383 number of drives, the longer this takes.
2384 .El
2385 .Ss Creating file systems on Vinum volumes
2386 You do not need to run
2387 .Xr disklabel 8
2388 before creating a file system on a
2389 .Nm
2390 volume.  Just run
2391 .Xr newfs 8 .
2392 Use the
2393 .Fl v
2394 option to state that the device is not divided into partitions.  For example, to
2395 create a file system on volume
2396 .Pa mirror ,
2397 enter the following command:
2398 .Pp
2399 .Dl "# newfs -v /dev/vinum/mirror"
2400 .Pp
2401 A number of other considerations apply to
2402 .Nm
2403 configuration:
2404 .Bl -bullet
2405 .It
2406 There is no advantage in creating multiple drives on a single disk.  Each drive
2407 uses 131.5 kB of data for label and configuration information, and performance
2408 will suffer when the configuration changes.  Use appropriately sized subdisks instead.
2409 .It
2410 It is possible to increase the size of a concatenated
2411 .Nm
2412 plex, but currently the size of striped and RAID-5 plexes cannot be increased.
2413 Currently the size of an existing UFS file system also cannot be increased, but
2414 it is planned to make both plexes and file systems extensible.
2415 .El
2416 .Sh STATE MANAGEMENT
2417 Vinum objects have the concept of
2418 .Em state .
2419 See
2420 .Xr vinum 4
2421 for more details.  They are only completely accessible if their state is
2422 .Em up .
2423 To change an object state to
2424 .Em up ,
2425 use the
2426 .Ic start
2427 command.  To change an object state to
2428 .Em down ,
2429 use the
2430 .Ic stop
2431 command.  Normally other states are created automatically by the relationship
2432 between objects.  For example, if you add a plex to a volume, the subdisks of
2433 the plex will be set in the
2434 .Em empty
2435 state, indicating that, though the hardware is accessible, the data on the
2436 subdisk is invalid.  As a result of this state, the plex will be set in the
2437 .Em faulty
2438 state.
2439 .Ss The `reviving' state
2440 In many cases, when you start a subdisk the system must copy data to the
2441 subdisk.  Depending on the size of the subdisk, this can take a long time.
2442 During this time, the subdisk is set in the
2443 .Em reviving
2444 state.  On successful completion of the copy operation, it is automatically set
2445 to the
2446 .Em up
2447 state.  It is possible for the process performing the revive to be stopped and
2448 restarted.  The system keeps track of how far the subdisk has been revived, and
2449 when the
2450 .Ic start
2451 command is reissued, the copying continues from this point.
2452 .Pp
2453 In order to maintain the consistency of a volume while one or more of its plexes
2454 is being revived,
2455 .Nm
2456 writes to subdisks which have been revived up to the point of the write.  It may
2457 also read from the plex if the area being read has already been revived.
2458 .Sh GOTCHAS
2459 The following points are not bugs, and they have good reasons for existing, but
2460 they have shown to cause confusion.  Each is discussed in the appropriate
2461 section above.
2462 .Bl -enum
2463 .It
2464 .Nm
2465 drives are
2466 .Ux
2467 disk partitions and must have the partition type
2468 .Em vinum .
2469 This is different from ccd, which expects partitions of type
2470 .Em 4.2BSD .
2471 This behaviour of
2472 .Nm ccd
2473 is an invitation to shoot yourself in the foot: with
2474 .Nm ccd
2475 you can easily overwrite a file system.
2476 .Nm
2477 will not permit this.
2478 .Pp
2479 For similar reasons, the
2480 .Nm Ic start
2481 command will not accept a drive on partition
2482 .Dq Li c .
2483 Partition
2484 .Dq Li c
2485 is used by the system to represent the whole disk, and must be of type
2486 .Em unused .
2487 Clearly there is a conflict here, which
2488 .Nm
2489 resolves by not using the
2490 .Dq Li c
2491 partition.
2492 .It
2493 When you create a volume with multiple plexes,
2494 .Nm
2495 does not automatically initialize the plexes.  This means that the contents are
2496 not known, but they are certainly not consistent.  As a result, by default
2497 .Nm
2498 sets the state of all newly-created plexes except the first to
2499 .Em faulty .
2500 In order to synchronize them with the first plex, you must
2501 .Ic start
2502 them, which causes
2503 .Nm
2504 to copy the data from a plex which is in the
2505 .Em up
2506 state.  Depending on the size of the subdisks involved, this can take a long
2507 time.
2508 .Pp
2509 In practice, people aren't too interested in what was in the plex when it was
2510 created, and other volume managers cheat by setting them
2511 .Em up
2512 anyway.
2513 .Nm
2514 provides two ways to ensure that newly created plexes are
2515 .Em up :
2516 .Bl -bullet
2517 .It
2518 Create the plexes and then synchronize them with
2519 .Nm Ic start .
2520 .It
2521 Create the volume (not the plex) with the keyword
2522 .Cm setupstate ,
2523 which tells
2524 .Nm
2525 to ignore any possible inconsistency and set the plexes to be
2526 .Em up .
2527 .El
2528 .It
2529 Some of the commands currently supported by
2530 .Nm
2531 are not really needed.  For reasons which I don't understand, however, I find
2532 that users frequently try the
2533 .Ic label
2534 and
2535 .Ic resetconfig
2536 commands, though especially
2537 .Ic resetconfig
2538 outputs all sort of dire warnings.  Don't use these commands unless you have a
2539 good reason to do so.
2540 .It
2541 Some state transitions are not very intuitive.  In fact, it's not clear whether
2542 this is a bug or a feature.  If you find that you can't start an object in some
2543 strange state, such as a
2544 .Em reborn
2545 subdisk, try first to get it into
2546 .Em stopped
2547 state, with the
2548 .Ic stop
2549 or
2550 .Ic stop Fl f
2551 commands.  If that works, you should then be able to start it.  If you find
2552 that this is the only way to get out of a position where easier methods fail,
2553 please report the situation.
2554 .It
2555 If you build the kernel module with the
2556 .Fl D Ns Dv VINUMDEBUG
2557 option, you must also build
2558 .Nm
2559 with the
2560 .Fl D Ns Dv VINUMDEBUG
2561 option, since the size of some data objects used by both components depends on
2562 this option.  If you don't do so, commands will fail with a corresponding error
2563 message.
2564 .It
2565 The
2566 .Nm Ic read
2567 command has a particularly emetic syntax.  Once it was the only way to start
2568 .Nm ,
2569 but now the preferred method is with
2570 .Nm Ic start .
2571 .Nm Ic read
2572 should be used for maintenance purposes only.  Note that its syntax has changed,
2573 and the arguments must be disk slices, such as
2574 .Pa /dev/da0 ,
2575 not partitions such as
2576 .Pa /dev/da0e .
2577 .El
2578 .\"XXX.Sh BUGS
2579 .Sh FILES
2580 .Bl -tag -width /dev/vinum/control -compact
2581 .It Pa /dev/vinum
2582 directory with device nodes for
2583 .Nm
2584 objects
2585 .It Pa /dev/vinum/control
2586 control device for
2587 .Nm
2588 .It Pa /dev/vinum/plex
2589 directory containing device nodes for
2590 .Nm
2591 plexes
2592 .It Pa /dev/vinum/sd
2593 directory containing device nodes for
2594 .Nm
2595 subdisks
2596 .El
2597 .Sh ENVIRONMENT
2598 .Bl -tag -width VINUM_DATEFORMAT
2599 .It Ev VINUM_HISTORY
2600 The name of the log file, by default
2601 .Pa /var/log/vinum_history .
2602 .It Ev VINUM_DATEFORMAT
2603 The format of dates in the log file, by default
2604 .Qq Li %e %b %Y %H:%M:%S .
2605 .It Ev EDITOR
2606 The name of the editor to use for editing configuration files, by default
2607 .Nm vi .
2608 .El
2609 .Sh SEE ALSO
2610 .Xr strftime 3 ,
2611 .Xr vinum 4 ,
2612 .Xr disklabel 8 ,
2613 .Xr newfs 8
2614 .Pp
2615 .Pa http://www.vinumvm.org/vinum.html ,
2616 .Pa http://www.vinumvm.org/vinum-debugging.html .
2617 .Sh AUTHORS
2618 .An Greg Lehey Aq grog@lemis.com
2619 .Sh HISTORY
2620 The
2621 .Nm
2622 command first appeared in
2623 .Fx 3.0 .
2624 The RAID-5 component of
2625 .Nm
2626 was developed for Cybernet Inc.\&
2627 .Pq Pa www.cybernet.com
2628 for its NetMAX product.