summaryrefslogtreecommitdiffstats
path: root/sbin/vinum/vinum.8
blob: fd0d23d83b1886c1d45cb045c9f88de3bb6216a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
.\"  Hey, Emacs, edit this file in -*- nroff-fill -*- mode
.\"
.Dd 15 January 1999
.Dt vinum 8
.Os FreeBSD
.Sh NAME
.Nm vinum
.Nd Logical Volume Manager control program
.Sh SYNOPSIS
.Nm
.Op command
.Op Fl options
.Sh COMMANDS
.Cd create
.Ar description-file
.in +1i
Create a volume as described in 
.Ar description-file
.in
.\" XXX remove this
.Cd attach Ar plex Ar volume 
.Op Nm rename
.Cd attach Ar subdisk Ar plex Ar [offset]
.Op Nm rename
.in +1i
Attach a plex to a volume, or a subdisk to a plex.
.in
.\" XXX remove this
.Cd debug
.in +1i
Cause the volume manager to enter the kernel debugger.
.in
.Cd debug
.Ar flags
.in +1i
Set debugging flags.
.in
.Cd detach
.Op Ar plex | subdisk
.in +1i
Detach a plex or subdisk from the volume or plex to which it is attached.
.in
.Cd info
.Op Fl v
.in +1i
List information about volume manager state.
.in
.Cd init
.Op Fl v
.in +1i
.\" XXX
Initialize a plex by writing zeroes to all its subdisks.
.in
.Cd label
.Ar volume
.in +1i
Create a volume label
.in
.Cd list
.Op Fl r
.Op Fl s
.Op Fl v
.Op Fl V
.Op volume | plex | subdisk
.in +1i
List information about specified objects
.in
.Cd l
.Op Fl r
.Op Fl s
.Op Fl v
.Op Fl V
.Op volume | plex | subdisk
.in +1i
List information about specified objects (alternative to
.Cd list
command)
.in
.Cd ld
.Op Fl r
.Op Fl s
.Op Fl v
.Op Fl V
.Op volume
.in +1i
List information about drives
.in
.Cd ls
.Op Fl r
.Op Fl s
.Op Fl v
.Op Fl V
.Op subdisk
.in +1i
List information about subdisks
.in
.Cd lp
.Op Fl r
.Op Fl s
.Op Fl v
.Op Fl V
.Op plex
.in +1i
List information about plexes
.in
.Cd lv
.Op Fl r
.Op Fl s
.Op Fl v
.Op Fl V
.Op volume
.in +1i
List information about volumes
.in
.Cd makedev
.in +1i
Remake the device nodes in 
.Ar /dev/vinum .
.in
.Cd quit
.in +1i
Exit the
.Nm
program when running in interactive mode.  Normally this would be done by
entering the
.Ar EOF
character.
.in
.Cd read
.Ar disk Op disk...
.in +1i
Read the
.Nm
configuration from the specified disks.
.in
.Cd rename Op Fl r
.Ar [ drive | subdisk | plex | volume ]
.Ar newname
.in +1i
Change the name of the specified object.
.ig
XXX
.in
.Cd replace
.Ar [ subdisk | plex ]
.Ar newobject
.in +1i
Replace the object with an identical other object.  XXX not implemented yet.
..
.in
.Cd resetconfig
.in +1i
Reset the complete
.Nm
configuration.
.in
.Cd resetstats
.Op Fl r
.Op volume | plex | subdisk
.in +1i
Reset statistisc counters for the specified objects, or for all objects if none
are specified.
.in
.Cd rm 
.Op Fl f
.Op Fl r
.Ar volume | plex | subdisk
.in +1i
Remove an object
.in
.ig
XXX
.Cd set
.Op Fl f
.Ar state
.Ar volume | plex | subdisk | disk
.in +1i
Set the state of the object to \fIstate\fP\|
.in
..
.Cd setdaemon
.Op value
.in +1i
Set dæmon configuration.
.in
.Cd start
.Op volume | plex | subdisk
.in +1i
Allow the system to access the objects
.in
.Cd stop
.Op Fl f
.Op volume | plex | subdisk
.in +1i
Terminate access the objects
.in
.Sh DESCRIPTION
.Nm
is a utility program to communicate with the \fBVinum\fP\| logical volume
manager.  See
.Xr vinum 4
for more information about the volume manager.
.Xr vinum 8
is designed either for interactive use, when started without a command, or to
execute a single command if the command is supplied as arguments to
.Nm vinum .
In interactive mode, 
.Nm
maintains a command line history.
.Ss OPTIONS
.Nm
commands may optionally be followed by an option.  Any of the following options
may be specified with any command, but in some cases they do not make any
difference: cases, the options are ignored.  For example, the
.Nm stop
command ignores the 
.Fl v
and
.Fl V
options.
.Bl -hang
.It Cd -v
The
.Nm -v
option can be used with any command to request more detailed information.  
.It Cd -V
The
.Nm -V
option can be used with any command to request more detailed information than
the
.Nm -v
option provides.
.It Cd -f
The
.Nm -f
option overrides safety checks.  Use with extreme care.  This option is for
emergency use only.  For example, the command
.Bd -unfilled -offset indent
rm -f myvolume
.Ed
.Pp
removes
.Nm myvolume
even if it is open.  Any subsequent access to the volume will almost certainly
cause a panic.
.It Cd -r
The
.Nm -r
(``recursive'') option is used by the list commands to display information not
only about the specified objects, but also about subordinate objects.  For
example, in conjnction with the
.Nm lv
command, the
.Nm -r
option will also show information about the plexes and subdisks belonging to the
volume.
.It Cd -s
The
.Nm -s
option is used by the list commands to display statistical information.
.El
.Pp
.Ss COMMANDS IN DETAIL
.Pp
.Nm
commands perform the following functions:
.Bl -hang
.It Nm attach Ar plex Ar volume
.Op Nm rename
.if n .sp -1v
.if t .sp -.6v
.It Nm attach Ar subdisk Ar plex Ar [offset]
.Op Nm rename
.sp
.Nm
.Ar attach
inserts the specified plex or subdisk in a volume or plex.  In the case of a
subdisk, an offset in the plex may be specified.  If it is not, the subdisk will
be attached at the first possible location.  After attaching a plex to a
non-empty volume,
.Nm
reintegrates the plex.
.Pp
If the keyword
.Nm rename
is specified,
.Nm
renames the object (and in the case of a plex, any subordinate subdisks) to fit
in with the default
.Nm 
naming convention.
.Pp
A number of considerations apply to attaching subdisks:
.Bl -bullet
.It
Subdisks can normally only be attached to concatenated plexes.
.It
If a striped or RAID-5 plex is missing a subdisk (for example after drive
failure), it may be replaced by a subdisk of the same size only.  No other
attachment of subdisks is currently allowed.
.It
For concatenated plexes, the
.Ar offset
parameter specifies the offset in blocks from the beginning of the plex.  For
striped and RAID-5 plexes, it specifies the offset of the first block of the
subdisk: in other words, the offset is the numerical position of the subdisk
multiplied by the stripe size.  For example, in a plex of block size 256k, the
first subdisk will have offset 0, the second offset 256k, the third 512k, etc.
This calculation ignores parity blocks in RAID-5 plexes.
.El
.It Nm create Ar description-file
.sp
.Nm
.Ar create
is used to create any object.  In view of the relatively complicated
relationship and the potential dangers involved in creating a
.Nm
object, there is no interactive interface to this function.  See the section
CONFIGURATION FILE below for more information.
.It Nm debug
.Pp
.Nm
.Ar debug
is used to enter the remote kernel debugger.  It is only activated if
.Nm
is built with the 
.Ar VINUMDEBUG 
option.  This option will stop the execution of the operating system until the
kernel debugger is exited.  If remote debugging is set and there is no remote
connection for a kernel debugger, it will be necessary to reset the system and
reboot in order to leave the debugger.
.It Nm debug
.Ar flags
.Pp
Set a bit mask of internal debugging flags.  These will change without warning
as the product matures; to be certain, read the header file
.Pa sys/dev/vinumvar.h .
The bit mask is composed of the following values:
.Bl -hang
.It DEBUG_ADDRESSES (1)
.br
Show buffer information during requests
.It DEBUG_NUMOUTPUT (2)
.br
Show the value of 
.Dv vp->v_numoutput.
.It DEBUG_RESID (4)
.br
Go into debugger in 
.Fd complete_rqe.
.It DEBUG_LASTREQS (8)
.br
Keep a circular buffer of last requests.
.It DEBUG_REVIVECONFLICT (16)
.br
Print info about revive conflicts.
.It DEBUG_REMOTEGDB (256)
.br
Go into remote
.Ic gdb
when the
.Nm debug
command is issued.
.El
.It Nm detach Op Fl f 
.Ar plex
.if n .sp -1v
.if t .sp -.6v
.It Nm detach Op Fl f 
.Ar subdisk
.sp
.Nm
.Ar detach
removes the specified plex or subdisk from the volume or plex to which it is
attached.  If removing the object would impair the data integrity of the volume,
the operation will fail unless the
.Fl f
option is specified.  If the object is named after the object above it (for
example, subdisk vol1.p7.s0 attached to plex vol1.p7), the name will be changed
by prepending the text ``ex-'' (for example, ex-vol1.p7.s0).  If necessary, the
name will be truncated in the process.
.Pp
.Nm detach
does not reduce the number of subdisks in a striped or RAID-5 plex.  Instead,
the subdisk is marked absent, and can later be replaced with the
.Nm attach
command.
.It Nm info
.br
.Nm
.Ar info
displays information about
.Nm
memory usage.  This is intended primarily for debugging.  With the 
.Fl v
option, it will give detailed information about the memory areas in use.
.Pp
With the
.Fl V
option,
.Ar info
displays information about the last up to 64 I/O requests handled by the
.Nm
driver.  This information is only collected if debug flag 8 is set.  The format
looks like:
.Pp
.Bd -literal
vinum -> info -V
Flags: 0x200    1 opens
Total of 38 blocks malloced, total memory: 16460
Maximum allocs:       56, malloc table at 0xf0f72dbc

Time             Event       Buf        Dev     Offset          Bytes   SD      SDoff   Doffset Goffset

14:40:00.637758 1VS Write 0xf2361f40    0x5b03  0x10            16384
14:40:00.639280 2LR Write 0xf2361f40    0x5b03  0x10            16384
14:40:00.639294 3RQ Read  0xf2361f40    0x427   0x104109        8192    19      0       0       0
14:40:00.639455 3RQ Read  0xf2361f40    0x417   0xd2109         8192    17      0       0       0
14:40:00.639529 3RQ Read  0xf2361f40    0x40f   0x6e109         8192    16      0       0       0
14:40:00.652978 4DN Read  0xf2361f40    0x427   0x104109        8192    19      0       0       0
14:40:00.667040 4DN Read  0xf2361f40    0x40f   0x6e109         8192    16      0       0       0
14:40:00.668556 4DN Read  0xf2361f40    0x417   0xd2109         8192    17      0       0       0
14:40:00.669777 6RP Write 0xf2361f40    0x427   0x104109        8192    19      0       0       0
14:40:00.685547 4DN Write 0xf2361f40    0x427   0x104109        8192    19      0       0       0
.Ed
.Pp
The 
.Ar Buf
field always contains the address of the user buffer header.  This can be used
to identify the requests associated with a user request, though this is not 100%
reliable: theoretically two requests in sequence could use the same buffer
header, though this is not common.  The beginning of a request can be identified
by the event
.Ar 1VS .
The example above shows the requests involved in a single user request.
.Pp
The
.Ar Event
field contains information related to the sequence of events in the request
chain.  The digit
.Ar 1
to 
.Ar 6
indicates the approximate sequence of events, and the two-letter abbreviation is
a mnemonic for the location
.Bl -hang
.It 1VS
(vinumstrategy) shows information about the user request on entry to
.Fd vinumstrategy .
The device number is the
.Nm
device, and offset and length are the user parameters.  This is always the
beginning of a request sequence.
.It 2LR
(launch_requests) shows the user request just prior to launching the low-level
.Nm
requests in the function
.Fd launch_requests.
The parameters should be the same as in the
.Ar 1VS
information.
.Pp
In the following requests,
.Ar Dev
is the device number of the associated disk partition,
.Ar Offset 
is the offset from the beginning of the partition,
.Ar SD
is the subdisk index in 
.Dv vinum_conf ,
.Ar SDoff
is the offset from the beginning of the subdisk,
.Ar Doffset
is the offset of the associated data request, and
.Ar Goffset
is the offset of the associated group request, where applicable.
.It 3RQ
(request) shows one of possibly several low-level
.Nm
requests which are launched to satisfy the high-level request.  This information
is also logged in 
.Fd launch_requests.
.It 4DN
(done) is called from 
.Fd complete_rqe,
showing the completion of a request.  This completion should match a request
launched either at stage
.Ar 4DN
from 
.Fd launch_requests, 
or from 
.Fd complete_raid5_write
at stage
.Ar 5RD
or
.Ar 6RP .
.It 5RD
(RAID-5 data) is called from 
.Fd complete_raid5_write
and represents the data written to a RAID-5 data stripe after calculating
parity.
.It 6RP
(RAID-5 parity) is called from 
.Fd complete_raid5_write
and represents the data written to a RAID-5 parity stripe after calculating
parity.
.El
.\" XXX
.It Nm init Ar plex
.Pp
.Nm
.Ar init
initializes a plex by writing zeroes to all its subdisks.  This is the only way
to ensure consistent data in a plex.  You must perform this initialization
before using a RAID-5 plex.  It is also recommended for other new plexes.
.Pp
.Nm 
initializes all subdisks of a plex in parallel.  Since this operation can take a
long time, it is performed in the background.  
.Nm
prints a console message when the initialization is complete.
.It Nm label
.Ar volume
.Pp
The
.Nm label
command writes a
.Ar ufs
style volume label on a volume.  It is a simple alternative to an appropriate
call to
.Ar disklabel . 
This is needed because some
.Ar ufs
commands still read the disk to find the label instead of using the correct
.Ar ioctl
call to access it.
.Nm
maintains a volume label separately from the volume data, so this command is not
needed for
.Ar newfs .
This command is deprecated.
.Pp
.It Nm list
.Op Fl r
.Op Fl V
.Op volume | plex | subdisk
.if n .sp -1v
.if t .sp -.6v
.It Nm l
.Op Fl r
.Op Fl V
.Op volume | plex | subdisk
.if n .sp -1v
.if t .sp -.6v
.It Nm ld
.Op Fl r
.Op Fl s
.Op Fl v
.Op Fl V
.Op volume
.if n .sp -1v
.if t .sp -.6v
.It Nm ls
.Op Fl r
.Op Fl s
.Op Fl v
.Op Fl V
.Op subdisk
.if n .sp -1v
.if t .sp -.6v
.It Nm lp
.Op Fl r
.Op Fl s
.Op Fl v
.Op Fl V
.Op plex
.if n .sp -1v
.if t .sp -.6v
.It Nm lv
.Op Fl r
.Op Fl s
.Op Fl v
.Op Fl V
.Op volume
.Pp
.Ar list
is used to show information about the specified object.  If the argument is
omitted, information is shown about all objects known to
.Nm vinum .
The
.Ar l
command is a synonym for
.Ar list .
.Pp
The
.Fl r
option relates to volumes and plexes: if specified, it recursively lists
information for the subdisks and (for a volume) plexes subordinate to the
objects.  The commands
.Ar lv ,
.Ar lp ,
.Ar ls 
and 
.Ar ld
commands list only volumes, plexes, subdisks and drives respectively.  This is
particularly useful when used without parameters.
.Pp
The
.Fl s
option causes
.Nm
to output device statistics, the
.Op Fl v
(verbose) option causes some additional information to be output, and the
.Op Fl V
causes considerable additional information to be output.
.It Nm makedev
.br
The
.Nm makedev
command removes the directory /dev/vinum and recreates it with device nodes
which reflect the current configuration.  This command is not intended for
general use, and is provided for emergency use only.
.Pp
.It Nm quit
Exit the
.Nm
program when running in interactive mode.  Normally this would be done by
entering the
.Ar EOF
character.
.It Nm read
.Ar disk Op disk...
.Pp
The
.Nm read
command scans the specified disks for
.Nm 
partitions containing previously created configuration information.  It reads
the configuration in order from the most recently updated to least recently
updated configuration.  This is the normal method used to start
.Nm vinum .
.Nm
maintains an up-to-date copy of all configuration information on each disk
partition.  You must specify all of the partitions in a configuration as the
parameter to this command.
.Nm
.Nm read
will accept the names of non-Vinum partitions, so you can specify all partitions
upon which a
.Nm
partition might be resident to this command.
.It Nm rename
.Op Fl r
.Ar [ drive | subdisk | plex | volume ]
.Ar newname
.Pp
Change the name of the specified object.  If the
.Fl r
option is specified, subordinate objects will be named by the default rules:
plex names will be formed by appending .p\f(BInumber\fP to the volume name, and
subdisk names will be formed by appending .s\f(BInumber\fP to the plex name.
.It Nm replace
.Ar [ subdisk | plex ]
.Ar newobject
.Pp
Replace the object with an identical other object.  This command has not yet
been implemented.
.It Nm resetconfig
.Pp
The
.Nm resetconfig
command completely obliterates the
.Nm
configuration on a system.  Use this command only when you want to completely
delete the configuration.
.Nm
will ask for confirmation: you must type in the words NO FUTURE exactly
as shown:
.Bd -unfilled -offset indent
# \f(CBvinum resetconfig\f(CW

WARNING!  This command will completely wipe out your vinum
configuration.  All data will be lost.  If you really want
to do this, enter the text

NO FUTURE
Enter text -> \f(BINO FUTURE\fP
Vinum configuration obliterated
.Ed
.ft R
.Pp
As the message suggests, this is a last-ditch command.  Don't use it unless you
have an existing configuration which you never want to see again.
.It Nm resetstats
.Op Fl r
.Op volume | plex | subdisk
.Pp
.Nm
maintains a number of statistical counters for each object.  See the header file
.Fi vinumvar.h
for more information.
.\" XXX put it in here when it's finalized
Use the 
.Nm resetstats
command to reset these counters.  In conjunction with the
.Fl r
option, 
.Nm
also resets the counters of subordinate objects.
.It Nm rm 
.Op Fl f
.Op Fl r
.Ar volume | plex | subdisk
.Pp
.Nm rm
removes an object from the
.Nm
configuration.  Once an object has been removed, there is no way to recover it.
Normally
.Nm
performs a large amount of consistency checking before removing an object.  The
.Fl f
option tells
.Nm
to omit this checking and remove the object anyway.  Use this option with great
care: it can result in total loss of data on a volume.
.Pp
Normally,
.Nm
refuses to remove a volume or plex if it has subordinate plexes or subdisks
respectively.  You can tell
.Nm
to remove the object anyway by using the
.Fl f
flag, or you can cause
.Nm
to remove the subordinate objects as well by using the
.Fl r
(recursive) flag.  If you remove a volume with the
.Fl r
flag, it will remove both the plexes and the subdisks which belong to the
plexes.
.ig
.It Nm set
.Op Fl f
.Ar state
.Ar volume | plex | subdisk | disk
.Nm set
sets the state of the specified object to one of the valid states (see OBJECT
STATES below).  Normally
.Nm
performs a large amount of consistency checking before making the change.  The
.Fl f
option tells
.Nm
to omit this checking and perform the change anyway.  Use this option with great
care: it can result in total loss of data on a volume.
.\"XXX
.Nm This command has not yet been implemented.
..
.It Nm setdaemon
.Op value
.Pp
.Nm setdaemon
sets a variable bitmask for the
.Nm
dæmon.  This command is temporary and will be replaced.  Currently, the bit mask
may contain the bits 1 (log every action to syslog) and 4 (don't update
configuration).  Option bit 4 can be useful for error recovery.
.It Nm start
.Op volume | plex | subdisk
.Pp
.Nm start
starts one or more
.Nm
objects.  To start a plex in a multi-plex volume, the data must be copied from
another plex in the volume.  This frequently takes a long time and is done in
the background.
.ig
XXX When invoked without arguments, it checks all disks connected to the system
for BSD partitions (type 165) and scans the partitions for a
.Nm
partition, which it calls a \fIdrive\fR\|.  The
.Nm
drive contains a header with all information about the data stored on the drive,
including the names of the other drives which are required in order to represent
plexes and volumes.
.\" XXX 
.Nm The scan function has not yet been implemented.
..
.It Nm stop
.Op Fl f
.Op volume | plex | subdisk
.Pp
.Nm stop
disables access to the specified objects and any subordinate objects.  It does
not remove the objects from the configuration.  They can be accessed again after
a
.Nm start 
command.
.Pp
By default, 
.Nm
does not remove active objects.  For example, you cannot remove a plex which is
attached to an active volume, and you cannot remove a volume which is open.  The
.Fl f
option tells
.Nm
to omit this checking and remove the object anyway.  Use this option with great
care and understanding: used incorrectly, it can result in serious data
corruption.
.El
.Ss CONFIGURATION FILE
.Nm
requires that all parameters to the
.Nm create
commands must be in a configuration file.  Entries in the configuration file
define volumes, plexes and subdisks, and may be in free format, except that each
entry must be on a single line.
.Pp
Some configuration file parameters specify a size (lengths, stripe sizes).
These lengths can be specified as bytes, as sectors of 512 bytes (by appending
the letter \f(CWb\fR), as kilobytes (by appending the letter \f(CWk\fR), as
megabytes (by appending the letter \f(CWm\fR) or as gigabytes (by appending the
letter \f(CWg\fR).  These quantities represent the values 2**10, 2**20 and 2**30
respectively.  For example, the value \f(CW16777216\fR bytes can also be written
as \f(CW16m\fR, \f(CW16384k\fR or \f(CW32768b\fR.
.Pp
The configuration file can contain the following entries:
.Pp
.Bl -hang -width 4n
.It Nm volume
.Ar name 
.Op options
.Pp
Define a volume with name
.Ar name .
.Pp
Options are:
.Pp
.Bl -hang -width 18n
.It Nm plex Ar plexname
Add the specified plex to the volume.  If
.Ar plexname
is specified as 
.Ar * ,
.Nm
will look for the definition of the plex as the next possible entry in the
configuration file after the definition of the volume.
.It Nm readpol Ar policy
Define a
.Ar read policy
for the volume.
.Ar policy
may be either 
.Nm round
or
.Nm prefer Ar plexname .
.Nm
satisfies a read request from only one of the plexes.  A
.Ar round
read policy specifies that each read should be performed from a different plex
in \fIround-robin\fR\| fashion.  A
.Ar prefer
read policy reads from the specified plex every time.
.It Nm setupstate
When creating a multi-plex volume, assume that the contents of all the plexes
are consistent.  This is normally not the case, and correctly you should use the
.Nm init
command to first bring them to a consistent state.  In the case of striped and
concatenated plexes, however, it does not normally cause problems to leave them
inconsistent: when using a volume for a file system or a swap partition, the
previous contents of the disks are not of interest, so they may be ignored.
If you want to take this risk, use this keyword.  It will only apply to the
plexes defined immediately after the volume in the configuration file.  If you
add plexes to a volume at a later time, you must integrate them.
.Pp
Note that you \fImust\fP\| use the
.Nm init
command with RAID-5 plexes: otherwise extreme data corruption will result if one
subdisk fails.
.fi
.El
.It Nm plex Op options
.Pp
Define a plex.  Unlike a volume, a plex does not need a name.  The options may
be:
.Pp
.Bl -hang -width 18n
.It Nm name Ar plexname
Specify the name of the plex.  Note that you must use the keyword
.Ar name
when naming a plex or subdisk.
.sp
.It Nm org Ar organization Op stripesize
.Pp
Specify the organization of the plex.
.Ar organization
can be one of 
.Ar concat ,
.Ar striped
or
.Ar raid5 .
For
.Ar striped
and
.Ar raid5 
plexes, the parameter
.Ar stripesize
must be specified, while for
.Ar concat
it must be omitted.  For type
.Ar striped ,
it specifies the width of each stripe.  For type
.Ar raid5 ,
it specifies the size of a group.  A group is a portion of a plex which
stores the parity bits all in the same subdisk.   It must be a factor of the plex size (in
other words, the result of dividing the plex size by the stripe size must be an
integer), and it must be a multiple of a disk sector (512 bytes).
.sp
For optimum performance, stripes should be at least 128 kB in size: anything
smaller will result in a significant increase in I/O activity due to mapping of
individual requests over multiple disks.  The increase in concurrency due to
this mapping will not make up for the increase in latency.  A good guideline for
stripe size is between 256 kB and 512 kB.
.Pp
A striped plex must have at least two subdisks (otherwise it is a concatenated
plex), and each must be the same size.  A RAID-5 plex must have at least three
subdisks, and each must be the same size.  In practice, a RAID-5 plex should
have at least 5 subdisks.
.Pp
.It Nm volume Ar volname
Add the plex to the specified volume.  If no
.Nm volume
keyword is specified, the plex will be added to the last volume mentioned in the
configuration file.
.sp
.It Nm sd Ar sdname Ar offset
Add the specified subdisk to the  plex at offset
.Ar offset .
.br
.fi
.El
.It Nm subdisk Op options
.Pp
Define a subdisk.  Options may be:
.Pp
.Bl -hang -width 18n
.nf
.sp
.It Nm name Ar name
Specify the name of a subdisk.  It is not necessary to specify a name for a
subdisk\(emsee OBJECT NAMING above.  Note that you must specify the keyword
.Ar name
if you wish to name a subdisk.
.sp
.It Nm plexoffset Ar offset
Specify the starting offset of the subdisk in the plex.  If not specified,
.Nm
allocates the space immediately after the previous subdisk, if any, or otherwise
at the beginning of the plex.
.sp
.It Nm driveoffset Ar offset
Specify the starting offset of the subdisk in the drive.  If not specified,
.Nm
allocates the first contiguous
.Ar length
bytes of free space on the drive.
.sp
.It Nm length Ar length
Specify the length of the subdisk.  This keyword must be specified.  There is no
default.
.Nm length
may be shortened to 
.Nm len .
.sp
.It Nm plex Ar plex
Specify the plex to which the subdisk belongs.  By default, the subdisk belongs
to the last plex specified.
.sp
.It Nm drive Ar drive
Specify the drive on which the subdisk resides.  By default, the subdisk resides
on the last drive specified.
.br
.fi
.El
.It Nm drive Ar name Op options
.Pp
Define a drive.  The option must be:
.Pp
.Bl -hang -width 18n
.It Nm device Ar devicename
Specify the device on which the drive resides.
.El
.El
.Sh EXAMPLE CONFIGURATION FILE
.Bd -literal
# Sample vinum configuration file
#
# Our drives
drive drive1 device /dev/da1h
drive drive2 device /dev/da2h
drive drive3 device /dev/da3h
drive drive4 device /dev/da4h
drive drive5 device /dev/da5h
drive drive6 device /dev/da6h
# A volume with one striped plex
volume tinyvol
 plex org striped 32b
  sd length 64m drive drive2
  sd length 64m drive drive4
volume stripe
 plex org striped 32b
  sd length 512m drive drive2
  sd length 512m drive drive4
# Two plexes
volume concat
 plex org concat
  sd length 100m drive drive2
  sd length 50m drive drive4
 plex org concat
  sd length 150m drive drive4
# A volume with one striped plex and one concatenated plex
volume strcon
 plex org striped 32b
  sd length 100m drive drive2
  sd length 100m drive drive4
 plex org concat
  sd length 150m drive drive2
  sd length 50m drive drive4
# a volume with a  RAID-5 and a striped plex
# note that the RAID-5 volume is longer by
# the length of one subdisk
volume vol5
 plex org striped 64k
  sd length 1000m drive drive2
  sd length 1000m drive drive4
 plex org raid5 32k
  sd length 500m drive drive1
  sd length 500m drive drive2
  sd length 500m drive drive3
  sd length 500m drive drive4
  sd length 500m drive drive5
.Ed
.Ss DRIVE LAYOUT CONSIDERATIONS
.Nm
drives are currently BSD disk partitions.  They must be of type
.Ar unused 
in order to avoid overwriting file systems.  In later versions of
.Nm
this requirement will change to type
.Ar vinum .
Use
.Nm disklabel
.Ar -e
to edit a partition type definition.  The following display shows a typical
partition layout as shown by
.Nm disklabel:
.Bd -literal
8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:    81920   344064    4.2BSD        0     0     0   # (Cyl.  240*- 297*)
  b:   262144    81920      swap                        # (Cyl.   57*- 240*)
  c:  4226725        0    unused        0     0         # (Cyl.    0 - 2955*)
  e:    81920        0    4.2BSD        0     0     0   # (Cyl.    0 - 57*)
  f:  1900000   425984    4.2BSD        0     0     0   # (Cyl.  297*- 1626*)
  g:  1900741  2325984    unused        0     0     0   # (Cyl. 1626*- 2955*)
.Ed
.sp
In this example, partition 
.Nm g
may be used as a
.Nm
partition.  Partitions 
.Nm a ,
.Nm e 
and
.Nm f
may be used as
.Nm UFS
file systems or
.Nm ccd
partitions.  Partition 
.Nm b
is a swap partition, and partition
.Nm c
represents the whole disk and should not be used for any other purpose.
.Pp
.Nm
uses the first 265 sectors on each partition for configuration information, so
the maximum size of a subdisk is 265 sectors smaller than the drive.
.Sh GOTCHAS
The following points are not bugs, and they have good reasons for existing, but
they have shown to cause confusion.  Each is discussed in the appropriate
section above.
.Bl -enum
.It
.Nm
will not create a device on UFS partitions.  Instead, it will return an error
message ``wrong partition type''.  The partition type must currently be
``unused''.
.It
When you create a volume with multiple plexes,
.Nm 
does not automatically initialize the plexes.  This means that the contents are
not known, but they are certainly not consistent.  As a result, by default 
.Nm
sets the state of all newly-created plexes except the first to
.Ar stale .
.sp
In practice, people aren't too interested in what was in the plex when it was
created, and other volume managers cheat by setting them 
.Ar up
anyway.
.Nm
provides two ways to ensure that newly created plexes are
.Ar up :
.Bl -bullet
.It
Create the plexes and then initialize them with
.Nm vinum init .
.It
Create the volume (not the plex) with the keyword
.Ar setupstate ,
which tells
.Nm
to ignore any possible inconsistency and set the plexes to be
.Ar up .
.El
.It
Some of the commands currently supported by
.Nm
are not really needed.  For reasons which I don't understand, however, I find
that users frequently try the
.Nm label
and 
.Nm resetconfig
commands, though especially
.Nm resetconfig
outputs all sort of dire warnings.  Don't use these commands unless you have a
good reason to do so.
.It
Some state transitions are not very intuitive.  In fact, it's not clear whether
this is a bug or a feature.  If you find that you can't start an object in some
strange state, such as a
.Ar reborn
subdisk, try first to get it into
.Ar stopped
state, with the
.Nm stop
or
.Nm stop Ar -f
commands.  If that works, you should then be able to start it.  If you find 
that this is the only way to get out of a position where easier methods fail,
please report the situation.
.It
If you build the kernel module with the
.Ar -DVINUMDEBUG
option, you must also build
.Nm vinum(8)
with the
.Ar -DVINUMDEBUG
option, since the size of some data objects used by both components depends on
this option.  If you don't do so, commands will fail with the message
.Ar Invalid argument ,
and a console message will be logged such as
.Pp
.Bd -literal
vinumioctl: invalid ioctl from process 247 (vinum): c0e44642
.Ed
.Pp
This error may also occur if you use old versions of kld or userland program.
.El
.\"XXX.Sh BUGS
.Sh FILES
.Ar /dev/vinum
- directory with device nodes for
.Nm
objects.
.br
.Ar /dev/vinum/control
- control device for
.Nm vinum 
.br
.Ar /dev/vinum/plex
- directory containing device nodes for
.Nm
plexes.
.br
.Ar /dev/vinum/sd
- directory containing device nodes for
.Nm
subdisks.
.Sh SEE ALSO
.Xr vinum 4 ,
.Xr disklabel 8 ,
.Nm http://www.lemis.com/vinum.html ,
.Nm http://www.lemis.com/vinum-debugging.html .
.Sh AUTHOR
Greg Lehey 
.Pa <grog@lemis.com> .
.Sh HISTORY
The
.Nm
command first appeared in FreeBSD 3.0.
OpenPOWER on IntegriCloud