]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - sbin/camcontrol/camcontrol.8
MFC r199079, r199101:
[FreeBSD/stable/8.git] / sbin / camcontrol / camcontrol.8
1 .\"
2 .\" Copyright (c) 1998, 1999, 2000, 2002, 2005, 2006, 2007 Kenneth D. Merry.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\" 3. The name of the author may not be used to endorse or promote products
14 .\"    derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\" $FreeBSD$
29 .\"
30 .Dd November 9, 2009
31 .Dt CAMCONTROL 8
32 .Os
33 .Sh NAME
34 .Nm camcontrol
35 .Nd CAM control program
36 .Sh SYNOPSIS
37 .Nm
38 .Aq Ar command
39 .Op device id
40 .Op generic args
41 .Op command args
42 .Nm
43 .Ic devlist
44 .Op Fl v
45 .Nm
46 .Ic periphlist
47 .Op device id
48 .Op Fl n Ar dev_name
49 .Op Fl u Ar unit_number
50 .Nm
51 .Ic tur
52 .Op device id
53 .Op generic args
54 .Nm
55 .Ic inquiry
56 .Op device id
57 .Op generic args
58 .Op Fl D
59 .Op Fl S
60 .Op Fl R
61 .Nm
62 .Ic identify
63 .Op device id
64 .Op generic args
65 .Nm
66 .Ic reportluns
67 .Op device id
68 .Op generic args
69 .Op Fl c
70 .Op Fl l
71 .Op Fl r Ar reporttype
72 .Nm
73 .Ic readcap
74 .Op device id
75 .Op generic args
76 .Op Fl b
77 .Op Fl h
78 .Op Fl H
79 .Op Fl N
80 .Op Fl q
81 .Op Fl s
82 .Nm
83 .Ic start
84 .Op device id
85 .Op generic args
86 .Nm
87 .Ic stop
88 .Op device id
89 .Op generic args
90 .Nm
91 .Ic load
92 .Op device id
93 .Op generic args
94 .Nm
95 .Ic eject
96 .Op device id
97 .Op generic args
98 .Nm
99 .Ic rescan
100 .Aq all | bus Ns Op :target:lun
101 .Nm
102 .Ic reset
103 .Aq all | bus Ns Op :target:lun
104 .Nm
105 .Ic defects
106 .Op device id
107 .Op generic args
108 .Aq Fl f Ar format
109 .Op Fl P
110 .Op Fl G
111 .Nm
112 .Ic modepage
113 .Op device id
114 .Op generic args
115 .Aq Fl m Ar page | Fl l
116 .Op Fl P Ar pgctl
117 .Op Fl b | Fl e
118 .Op Fl d
119 .Nm
120 .Ic cmd
121 .Op device id
122 .Op generic args
123 .Aq Fl a Ar cmd Op args
124 .Aq Fl c Ar cmd Op args
125 .Op Fl i Ar len Ar fmt
126 .Bk -words
127 .Op Fl o Ar len Ar fmt Op args
128 .Op Fl r Ar fmt
129 .Ek
130 .Nm
131 .Ic debug
132 .Op Fl I
133 .Op Fl P
134 .Op Fl T
135 .Op Fl S
136 .Op Fl X
137 .Op Fl c
138 .Aq all|off|bus Ns Op :target Ns Op :lun
139 .Nm
140 .Ic tags
141 .Op device id
142 .Op generic args
143 .Op Fl N Ar tags
144 .Op Fl q
145 .Op Fl v
146 .Nm
147 .Ic negotiate
148 .Op device id
149 .Op generic args
150 .Op Fl c
151 .Op Fl D Ar enable|disable
152 .Op Fl O Ar offset
153 .Op Fl q
154 .Op Fl R Ar syncrate
155 .Op Fl T Ar enable|disable
156 .Op Fl U
157 .Op Fl W Ar bus_width
158 .Op Fl v
159 .Nm
160 .Ic format
161 .Op device id
162 .Op generic args
163 .Op Fl q
164 .Op Fl r
165 .Op Fl w
166 .Op Fl y
167 .Nm
168 .Ic idle
169 .Op device id
170 .Op generic args
171 .Op Fl t Ar time
172 .Nm
173 .Ic standby
174 .Op device id
175 .Op generic args
176 .Op Fl t Ar time
177 .Nm
178 .Ic sleep
179 .Op device id
180 .Op generic args
181 .Nm
182 .Ic help
183 .Sh DESCRIPTION
184 The
185 .Nm
186 utility is designed to provide a way for users to access and control the
187 .Fx
188 CAM subsystem.
189 .Pp
190 The
191 .Nm
192 utility
193 can cause a loss of data and/or system crashes if used improperly.
194 Even
195 expert users are encouraged to exercise caution when using this command.
196 Novice users should stay away from this utility.
197 .Pp
198 The
199 .Nm
200 utility has a number of primary functions, many of which support an optional
201 device identifier.
202 A device identifier can take one of three forms:
203 .Bl -tag -width 14n
204 .It deviceUNIT
205 Specify a device name and unit number combination, like "da5" or "cd3".
206 Note that character device node names (e.g.\& /dev/da0) are
207 .Em not
208 allowed here.
209 .It bus:target
210 Specify a bus number and target id.
211 The bus number can be determined from
212 the output of
213 .Dq camcontrol devlist .
214 The lun defaults to 0.
215 .It bus:target:lun
216 Specify the bus, target and lun for a device.
217 (e.g.\& 1:2:0)
218 .El
219 .Pp
220 The device identifier, if it is specified,
221 .Em must
222 come immediately after the function name, and before any generic or
223 function-specific arguments.
224 Note that the
225 .Fl n
226 and
227 .Fl u
228 arguments described below will override any device name or unit number
229 specified beforehand.
230 The
231 .Fl n
232 and
233 .Fl u
234 arguments will
235 .Em not
236 override a specified bus:target or bus:target:lun, however.
237 .Pp
238 Most of the
239 .Nm
240 primary functions support these generic arguments:
241 .Bl -tag -width 14n
242 .It Fl C Ar count
243 SCSI command retry count.
244 In order for this to work, error recovery
245 .Pq Fl E
246 must be turned on.
247 .It Fl E
248 Instruct the kernel to perform generic SCSI error recovery for the given
249 command.
250 This is needed in order for the retry count
251 .Pq Fl C
252 to be honored.
253 Other than retrying commands, the generic error recovery in
254 the code will generally attempt to spin up drives that are not spinning.
255 It may take some other actions, depending upon the sense code returned from
256 the command.
257 .It Fl n Ar dev_name
258 Specify the device type to operate on, e.g.\& "da", "cd".
259 .It Fl t Ar timeout
260 SCSI command timeout in seconds.
261 This overrides the default timeout for
262 any given command.
263 .It Fl u Ar unit_number
264 Specify the device unit number, e.g.\& "1", "5".
265 .It Fl v
266 Be verbose, print out sense information for failed SCSI commands.
267 .El
268 .Pp
269 Primary command functions:
270 .Bl -tag -width periphlist
271 .It Ic devlist
272 List all physical devices (logical units) attached to the CAM subsystem.
273 This also includes a list of peripheral drivers attached to each device.
274 With the
275 .Fl v
276 argument, SCSI bus number, adapter name and unit numbers are printed as
277 well.
278 .It Ic periphlist
279 List all peripheral drivers attached to a given physical device (logical
280 unit).
281 .It Ic tur
282 Send the SCSI test unit ready (0x00) command to the given device.
283 The
284 .Nm
285 utility will report whether the device is ready or not.
286 .It Ic inquiry
287 Send a SCSI inquiry command (0x12) to a device.
288 By default,
289 .Nm
290 will print out the standard inquiry data, device serial number, and
291 transfer rate information.
292 The user can specify that only certain types of
293 inquiry data be printed:
294 .Bl -tag -width 4n
295 .It Fl D
296 Get the standard inquiry data.
297 .It Fl S
298 Print out the serial number.
299 If this flag is the only one specified,
300 .Nm
301 will not print out "Serial Number" before the value returned by the drive.
302 This is to aid in script writing.
303 .It Fl R
304 Print out transfer rate information.
305 .El
306 .It Ic identify
307 Send a ATA identify command (0xec) to a device.
308 .It Ic reportluns
309 Send the SCSI REPORT LUNS (0xA0) command to the given device.
310 By default,
311 .Nm
312 will print out the list of logical units (LUNs) supported by the target device.
313 There are a couple of options to modify the output:
314 .Bl -tag -width 14n
315 .It Fl c
316 Just print out a count of LUNs, not the actual LUN numbers.
317 .It Fl l
318 Just print out the LUNs, and don't print out the count.
319 .It Fl r Ar reporttype
320 Specify the type of report to request from the target:
321 .Bl -tag -width 012345678
322 .It default
323 Return the default report.
324 This is the
325 .Nm
326 default.
327 Most targets will support this report if they support the REPORT LUNS
328 command.
329 .It wellknown
330 Return only well known LUNs.
331 .It all
332 Return all available LUNs.
333 .El
334 .El
335 .Pp
336 .Nm
337 will try to print out LUN numbers in a reasonable format.
338 It can understand the peripheral, flat, LUN and extended LUN formats.
339 .It Ic readcap
340 Send the SCSI READ CAPACITY command to the given device and display
341 the results.
342 If the device is larger than 2TB, the SCSI READ CAPACITY (16) service
343 action will be sent to obtain the full size of the device.
344 By default,
345 .Nm
346 will print out the last logical block of the device, and the blocksize of
347 the device in bytes.
348 To modify the output format, use the following options:
349 .Bl -tag -width 5n
350 .It Fl b
351 Just print out the blocksize, not the last block or device size.
352 This cannot be used with
353 .Fl N
354 or
355 .Fl s .
356 .It Fl h
357 Print out the device size in human readable (base 2, 1K == 1024) format.
358 This implies
359 .Fl N
360 and cannot be used with
361 .Fl q
362 or
363 .Fl b .
364 .It Fl H
365 Print out the device size in human readable (base 10, 1K == 1000) format.
366 .It Fl N
367 Print out the number of blocks in the device instead of the last logical
368 block.
369 .It Fl q
370 Quiet, print out the numbers only (separated by a comma if
371 .Fl b
372 or
373 .Fl s
374 are not specified).
375 .It Fl s
376 Print out the last logical block or the size of the device only, and omit
377 the blocksize.
378 .El
379 .It Ic start
380 Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
381 start bit set.
382 .It Ic stop
383 Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
384 start bit cleared.
385 .It Ic load
386 Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
387 start bit set and the load/eject bit set.
388 .It Ic eject
389 Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
390 start bit cleared and the load/eject bit set.
391 .It Ic rescan
392 Tell the kernel to scan all busses in the system (with the
393 .Ar all
394 argument), the given bus (XPT_SCAN_BUS), or bus:target:lun
395 (XPT_SCAN_LUN) for new devices or devices that have gone away.
396 The user
397 may specify a scan of all busses, a single bus, or a lun.
398 Scanning all luns
399 on a target is not supported.
400 .It Ic reset
401 Tell the kernel to reset all busses in the system (with the
402 .Ar all
403 argument) or the given bus (XPT_RESET_BUS) by issuing a SCSI bus
404 reset for that bus, or to reset the given bus:target:lun
405 (XPT_RESET_DEV), typically by issuing a BUS DEVICE RESET message after
406 connecting to that device.
407 Note that this can have a destructive impact
408 on the system.
409 .It Ic defects
410 Send the SCSI READ DEFECT DATA (10) command (0x37) to the given device, and
411 print out any combination of: the total number of defects, the primary
412 defect list (PLIST), and the grown defect list (GLIST).
413 .Bl -tag -width 11n
414 .It Fl f Ar format
415 The three format options are:
416 .Em block ,
417 to print out the list as logical blocks,
418 .Em bfi ,
419 to print out the list in bytes from index format, and
420 .Em phys ,
421 to print out the list in physical sector format.
422 The format argument is
423 required.
424 Most drives support the physical sector format.
425 Some drives
426 support the logical block format.
427 Many drives, if they do not support the
428 requested format, return the data in an alternate format, along with sense
429 information indicating that the requested data format is not supported.
430 The
431 .Nm
432 utility
433 attempts to detect this, and print out whatever format the drive returns.
434 If the drive uses a non-standard sense code to report that it does not
435 support the requested format,
436 .Nm
437 will probably see the error as a failure to complete the request.
438 .It Fl G
439 Print out the grown defect list.
440 This is a list of bad blocks that have
441 been remapped since the disk left the factory.
442 .It Fl P
443 Print out the primary defect list.
444 .El
445 .Pp
446 If neither
447 .Fl P
448 nor
449 .Fl G
450 is specified,
451 .Nm
452 will print out the number of defects given in the READ DEFECT DATA header
453 returned from the drive.
454 .It Ic modepage
455 Allows the user to display and optionally edit a SCSI mode page.
456 The mode
457 page formats are located in
458 .Pa /usr/share/misc/scsi_modes .
459 This can be overridden by specifying a different file in the
460 .Ev SCSI_MODES
461 environment variable.
462 The
463 .Ic modepage
464 command takes several arguments:
465 .Bl -tag -width 12n
466 .It Fl d
467 Disable block descriptors for mode sense.
468 .It Fl b
469 Displays mode page data in binary format.
470 .It Fl e
471 This flag allows the user to edit values in the mode page.
472 The user may
473 either edit mode page values with the text editor pointed to by his
474 .Ev EDITOR
475 environment variable, or supply mode page values via standard input, using
476 the same format that
477 .Nm
478 uses to display mode page values.
479 The editor will be invoked if
480 .Nm
481 detects that standard input is terminal.
482 .It Fl l
483 Lists all available mode pages.
484 .It Fl m Ar mode_page
485 This specifies the number of the mode page the user would like to view
486 and/or edit.
487 This argument is mandatory unless
488 .Fl l
489 is specified.
490 .It Fl P Ar pgctl
491 This allows the user to specify the page control field.
492 Possible values are:
493 .Bl -tag -width xxx -compact
494 .It 0
495 Current values
496 .It 1
497 Changeable values
498 .It 2
499 Default values
500 .It 3
501 Saved values
502 .El
503 .El
504 .It Ic cmd
505 Allows the user to send an arbitrary ATA or SCSI CDB to any device.
506 The
507 .Ic cmd
508 function requires the
509 .Fl c
510 argument to specify SCSI CDB or the
511 .Fl a
512 argument to specify ATA Command Block registers values.
513 Other arguments are optional, depending on
514 the command type.
515 The command and data specification syntax is documented
516 in
517 .Xr cam_cdbparse 3 .
518 NOTE: If the CDB specified causes data to be transfered to or from the
519 SCSI device in question, you MUST specify either
520 .Fl i
521 or
522 .Fl o .
523 .Bl -tag -width 17n
524 .It Fl a Ar cmd Op args
525 This specifies the content of 12 ATA Command Block registers (command,
526 features, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp.
527 lba_high_exp, features_exp, sector_count, sector_count_exp).
528 .It Fl c Ar cmd Op args
529 This specifies the SCSI CDB.
530 SCSI CDBs may be 6, 10, 12 or 16 bytes.
531 .It Fl i Ar len Ar fmt
532 This specifies the amount of data to read, and how it should be displayed.
533 If the format is
534 .Sq - ,
535 .Ar len
536 bytes of data will be read from the device and written to standard output.
537 .It Fl o Ar len Ar fmt Op args
538 This specifies the amount of data to be written to a device, and the data
539 that is to be written.
540 If the format is
541 .Sq - ,
542 .Ar len
543 bytes of data will be read from standard input and written to the device.
544 .It Fl r Ar fmt
545 This specifies that 11 result ATA Command Block registers should be displayed
546 (status, error, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp,
547 lba_high_exp, sector_count, sector_count_exp), and how.
548 If the format is
549 .Sq - ,
550 11 result registers will be written to standard output in hex.
551 .El
552 .It Ic debug
553 Turn on CAM debugging printfs in the kernel.
554 This requires options CAMDEBUG
555 in your kernel config file.
556 WARNING: enabling debugging printfs currently
557 causes an EXTREME number of kernel printfs.
558 You may have difficulty
559 turning off the debugging printfs once they start, since the kernel will be
560 busy printing messages and unable to service other requests quickly.
561 The
562 .Ic debug
563 function takes a number of arguments:
564 .Bl -tag -width 18n
565 .It Fl I
566 Enable CAM_DEBUG_INFO printfs.
567 .It Fl P
568 Enable CAM_DEBUG_PERIPH printfs.
569 .It Fl T
570 Enable CAM_DEBUG_TRACE printfs.
571 .It Fl S
572 Enable CAM_DEBUG_SUBTRACE printfs.
573 .It Fl X
574 Enable CAM_DEBUG_XPT printfs.
575 .It Fl c
576 Enable CAM_DEBUG_CDB printfs.
577 This will cause the kernel to print out the
578 SCSI CDBs sent to the specified device(s).
579 .It all
580 Enable debugging for all devices.
581 .It off
582 Turn off debugging for all devices
583 .It bus Ns Op :target Ns Op :lun
584 Turn on debugging for the given bus, target or lun.
585 If the lun or target
586 and lun are not specified, they are wildcarded.
587 (i.e., just specifying a
588 bus turns on debugging printfs for all devices on that bus.)
589 .El
590 .It Ic tags
591 Show or set the number of "tagged openings" or simultaneous transactions
592 we attempt to queue to a particular device.
593 By default, the
594 .Ic tags
595 command, with no command-specific arguments (i.e., only generic arguments)
596 prints out the "soft" maximum number of transactions that can be queued to
597 the device in question.
598 For more detailed information, use the
599 .Fl v
600 argument described below.
601 .Bl -tag -width 7n
602 .It Fl N Ar tags
603 Set the number of tags for the given device.
604 This must be between the
605 minimum and maximum number set in the kernel quirk table.
606 The default for
607 most devices that support tagged queueing is a minimum of 2 and a maximum
608 of 255.
609 The minimum and maximum values for a given device may be
610 determined by using the
611 .Fl v
612 switch.
613 The meaning of the
614 .Fl v
615 switch for this
616 .Nm
617 subcommand is described below.
618 .It Fl q
619 Be quiet, and do not report the number of tags.
620 This is generally used when
621 setting the number of tags.
622 .It Fl v
623 The verbose flag has special functionality for the
624 .Em tags
625 argument.
626 It causes
627 .Nm
628 to print out the tagged queueing related fields of the XPT_GDEV_TYPE CCB:
629 .Bl -tag -width 13n
630 .It dev_openings
631 This is the amount of capacity for transactions queued to a given device.
632 .It dev_active
633 This is the number of transactions currently queued to a device.
634 .It devq_openings
635 This is the kernel queue space for transactions.
636 This count usually mirrors
637 dev_openings except during error recovery operations when
638 the device queue is frozen (device is not allowed to receive
639 commands), the number of dev_openings is reduced, or transaction
640 replay is occurring.
641 .It devq_queued
642 This is the number of transactions waiting in the kernel queue for capacity
643 on the device.
644 This number is usually zero unless error recovery is in
645 progress.
646 .It held
647 The held count is the number of CCBs held by peripheral drivers that have
648 either just been completed or are about to be released to the transport
649 layer for service by a device.
650 Held CCBs reserve capacity on a given
651 device.
652 .It mintags
653 This is the current "hard" minimum number of transactions that can be
654 queued to a device at once.
655 The
656 .Ar dev_openings
657 value above cannot go below this number.
658 The default value for
659 .Ar mintags
660 is 2, although it may be set higher or lower for various devices.
661 .It maxtags
662 This is the "hard" maximum number of transactions that can be queued to a
663 device at one time.
664 The
665 .Ar dev_openings
666 value cannot go above this number.
667 The default value for
668 .Ar maxtags
669 is 255, although it may be set higher or lower for various devices.
670 .El
671 .El
672 .It Ic negotiate
673 Show or negotiate various communication parameters.
674 Some controllers may
675 not support setting or changing some of these values.
676 For instance, the
677 Adaptec 174x controllers do not support changing a device's sync rate or
678 offset.
679 The
680 .Nm
681 utility
682 will not attempt to set the parameter if the controller indicates that it
683 does not support setting the parameter.
684 To find out what the controller
685 supports, use the
686 .Fl v
687 flag.
688 The meaning of the
689 .Fl v
690 flag for the
691 .Ic negotiate
692 command is described below.
693 Also, some controller drivers do not support
694 setting negotiation parameters, even if the underlying controller supports
695 negotiation changes.
696 Some controllers, such as the Advansys wide
697 controllers, support enabling and disabling synchronous negotiation for
698 a device, but do not support setting the synchronous negotiation rate.
699 .Bl -tag -width 17n
700 .It Fl a
701 Attempt to make the negotiation settings take effect immediately by sending
702 a Test Unit Ready command to the device.
703 .It Fl c
704 Show or set current negotiation settings.
705 This is the default.
706 .It Fl D Ar enable|disable
707 Enable or disable disconnection.
708 .It Fl O Ar offset
709 Set the command delay offset.
710 .It Fl q
711 Be quiet, do not print anything.
712 This is generally useful when you want to
713 set a parameter, but do not want any status information.
714 .It Fl R Ar syncrate
715 Change the synchronization rate for a device.
716 The sync rate is a floating
717 point value specified in MHz.
718 So, for instance,
719 .Sq 20.000
720 is a legal value, as is
721 .Sq 20 .
722 .It Fl T Ar enable|disable
723 Enable or disable tagged queueing for a device.
724 .It Fl U
725 Show or set user negotiation settings.
726 The default is to show or set
727 current negotiation settings.
728 .It Fl v
729 The verbose switch has special meaning for the
730 .Ic negotiate
731 subcommand.
732 It causes
733 .Nm
734 to print out the contents of a Path Inquiry (XPT_PATH_INQ) CCB sent to the
735 controller driver.
736 .It Fl W Ar bus_width
737 Specify the bus width to negotiate with a device.
738 The bus width is
739 specified in bits.
740 The only useful values to specify are 8, 16, and 32
741 bits.
742 The controller must support the bus width in question in order for
743 the setting to take effect.
744 .El
745 .Pp
746 In general, sync rate and offset settings will not take effect for a
747 device until a command has been sent to the device.
748 The
749 .Fl a
750 switch above will automatically send a Test Unit Ready to the device so
751 negotiation parameters will take effect.
752 .It Ic format
753 Issue the
754 .Tn SCSI
755 FORMAT UNIT command to the named device.
756 .Pp
757 .Em WARNING! WARNING! WARNING!
758 .Pp
759 Low level formatting a disk will destroy ALL data on the disk.
760 Use
761 extreme caution when issuing this command.
762 Many users low-level format
763 disks that do not really need to be low-level formatted.
764 There are
765 relatively few scenarios that call for low-level formatting a disk.
766 One reason for
767 low-level formatting a disk is to initialize the disk after changing
768 its physical sector size.
769 Another reason for low-level formatting a disk
770 is to revive the disk if you are getting "medium format corrupted" errors
771 from the disk in response to read and write requests.
772 .Pp
773 Some disks take longer than others to format.
774 Users should specify a
775 timeout long enough to allow the format to complete.
776 The default format
777 timeout is 3 hours, which should be long enough for most disks.
778 Some hard
779 disks will complete a format operation in a very short period of time
780 (on the order of 5 minutes or less).
781 This is often because the drive
782 does not really support the FORMAT UNIT command -- it just accepts the
783 command, waits a few minutes and then returns it.
784 .Pp
785 The
786 .Sq format
787 subcommand takes several arguments that modify its default behavior.
788 The
789 .Fl q
790 and
791 .Fl y
792 arguments can be useful for scripts.
793 .Pp
794 .Bl -tag -width 6n
795 .It Fl q
796 Be quiet, do not print any status messages.
797 This option will not disable
798 the questions, however.
799 To disable questions, use the
800 .Fl y
801 argument, below.
802 .It Fl r
803 Run in
804 .Dq report only
805 mode.
806 This will report status on a format that is already running on the drive.
807 .It Fl w
808 Issue a non-immediate format command.
809 By default,
810 .Nm
811 issues the FORMAT UNIT command with the immediate bit set.
812 This tells the
813 device to immediately return the format command, before the format has
814 actually completed.
815 Then,
816 .Nm
817 gathers
818 .Tn SCSI
819 sense information from the device every second to determine how far along
820 in the format process it is.
821 If the
822 .Fl w
823 argument is specified,
824 .Nm
825 will issue a non-immediate format command, and will be unable to print any
826 information to let the user know what percentage of the disk has been
827 formatted.
828 .It Fl y
829 Do not ask any questions.
830 By default,
831 .Nm
832 will ask the user if he/she really wants to format the disk in question,
833 and also if the default format command timeout is acceptable.
834 The user
835 will not be asked about the timeout if a timeout is specified on the
836 command line.
837 .El
838 .It Ic idle
839 Put ATA device into IDLE state. Optional parameter specifies automatic
840 idle timer value in seconds.
841 .It Ic standby
842 Put ATA device into STANDBY state. Optional parameter specifies automatic
843 standby timer value in seconds.
844 .It Ic sleep
845 Put ATA device into SLEEP state. Note that the only way get device out of
846 this state may be reset.
847 .It Ic help
848 Print out verbose usage information.
849 .El
850 .Sh ENVIRONMENT
851 The
852 .Ev SCSI_MODES
853 variable allows the user to specify an alternate mode page format file.
854 .Pp
855 The
856 .Ev EDITOR
857 variable determines which text editor
858 .Nm
859 starts when editing mode pages.
860 .Sh FILES
861 .Bl -tag -width /usr/share/misc/scsi_modes -compact
862 .It Pa /usr/share/misc/scsi_modes
863 is the SCSI mode format database.
864 .It Pa /dev/xpt0
865 is the transport layer device.
866 .It Pa /dev/pass*
867 are the CAM application passthrough devices.
868 .El
869 .Sh EXAMPLES
870 .Dl camcontrol eject -n cd -u 1 -v
871 .Pp
872 Eject the CD from cd1, and print SCSI sense information if the command
873 fails.
874 .Pp
875 .Dl camcontrol tur da0
876 .Pp
877 Send the SCSI test unit ready command to da0.
878 The
879 .Nm
880 utility will report whether the disk is ready, but will not display sense
881 information if the command fails since the
882 .Fl v
883 switch was not specified.
884 .Pp
885 .Bd -literal -offset indent
886 camcontrol tur da1 -E -C 4 -t 50 -v
887 .Ed
888 .Pp
889 Send a test unit ready command to da1.
890 Enable kernel error recovery.
891 Specify a retry count of 4, and a timeout of 50 seconds.
892 Enable sense
893 printing (with the
894 .Fl v
895 flag) if the command fails.
896 Since error recovery is turned on, the
897 disk will be spun up if it is not currently spinning.
898 The
899 .Nm
900 utility will report whether the disk is ready.
901 .Bd -literal -offset indent
902 camcontrol cmd -n cd -u 1 -v -c "3C 00 00 00 00 00 00 00 0e 00" \e
903         -i 0xe "s1 i3 i1 i1 i1 i1 i1 i1 i1 i1 i1 i1"
904 .Ed
905 .Pp
906 Issue a READ BUFFER command (0x3C) to cd1.
907 Display the buffer size of cd1,
908 and display the first 10 bytes from the cache on cd1.
909 Display SCSI sense
910 information if the command fails.
911 .Pp
912 .Bd -literal -offset indent
913 camcontrol cmd -n cd -u 1 -v -c "3B 00 00 00 00 00 00 00 0e 00" \e
914         -o 14 "00 00 00 00 1 2 3 4 5 6 v v v v" 7 8 9 8
915 .Ed
916 .Pp
917 Issue a WRITE BUFFER (0x3B) command to cd1.
918 Write out 10 bytes of data,
919 not including the (reserved) 4 byte header.
920 Print out sense information if
921 the command fails.
922 Be very careful with this command, improper use may
923 cause data corruption.
924 .Pp
925 .Bd -literal -offset indent
926 camcontrol modepage da3 -m 1 -e -P 3
927 .Ed
928 .Pp
929 Edit mode page 1 (the Read-Write Error Recover page) for da3, and save the
930 settings on the drive.
931 Mode page 1 contains a disk drive's auto read and
932 write reallocation settings, among other things.
933 .Pp
934 .Dl camcontrol rescan all
935 .Pp
936 Rescan all SCSI busses in the system for devices that have been added,
937 removed or changed.
938 .Pp
939 .Dl camcontrol rescan 0
940 .Pp
941 Rescan SCSI bus 0 for devices that have been added, removed or changed.
942 .Pp
943 .Dl camcontrol rescan 0:1:0
944 .Pp
945 Rescan SCSI bus 0, target 1, lun 0 to see if it has been added, removed, or
946 changed.
947 .Pp
948 .Dl camcontrol tags da5 -N 24
949 .Pp
950 Set the number of concurrent transactions for da5 to 24.
951 .Pp
952 .Bd -literal -offset indent
953 camcontrol negotiate -n da -u 4 -T disable
954 .Ed
955 .Pp
956 Disable tagged queueing for da4.
957 .Pp
958 .Bd -literal -offset indent
959 camcontrol negotiate -n da -u 3 -R 20.000 -O 15 -a
960 .Ed
961 .Pp
962 Negotiate a sync rate of 20MHz and an offset of 15 with da3.
963 Then send a
964 Test Unit Ready command to make the settings take effect.
965 .Sh SEE ALSO
966 .Xr cam 3 ,
967 .Xr cam_cdbparse 3 ,
968 .Xr cam 4 ,
969 .Xr pass 4 ,
970 .Xr xpt 4
971 .Sh HISTORY
972 The
973 .Nm
974 utility first appeared in
975 .Fx 3.0 .
976 .Pp
977 The mode page editing code and arbitrary SCSI command code are based upon
978 code in the old
979 .Xr scsi 8
980 utility and
981 .Xr scsi 3
982 library, written by Julian Elischer and Peter Dufault.
983 The
984 .Xr scsi 8
985 program first appeared in
986 .Bx 386 0.1.2.4 ,
987 and first appeared in
988 .Fx
989 in
990 .Fx 2.0.5 .
991 .Sh AUTHORS
992 .An Kenneth Merry Aq ken@FreeBSD.org
993 .Sh BUGS
994 The code that parses the generic command line arguments does not know that
995 some of the subcommands take multiple arguments.
996 So if, for instance, you
997 tried something like this:
998 .Bd -literal -offset indent
999 camcontrol cmd -n da -u 1 -c "00 00 00 00 00 v" 0x00 -v
1000 .Ed
1001 .Pp
1002 The sense information from the test unit ready command would not get
1003 printed out, since the first
1004 .Xr getopt 3
1005 call in
1006 .Nm
1007 bails out when it sees the second argument to
1008 .Fl c
1009 (0x00),
1010 above.
1011 Fixing this behavior would take some gross code, or changes to the
1012 .Xr getopt 3
1013 interface.
1014 The best way to circumvent this problem is to always make sure
1015 to specify generic
1016 .Nm
1017 arguments before any command-specific arguments.