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