CAMCONTROL(8)

๐Ÿ“ฆ version 15.1, in freebsd 14.5, freebsd 15.1

๐Ÿ’… NAME ๐Ÿ’…

okay so this is CAMCONTROL(8), a.k.a. the camcontrol utility โ€” the CAM control program, straight out of the System Manager's Manual. bestie, it lets users access and control the FreeBSD CAM subsystem described in cam(4). โœจ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

Here's the whole shape of it, no cap:

camcontrol โŸจcommandโŸฉ [device id] [generic args] [command args]
camcontrol devlist [-b] [-v]
camcontrol periphlist [device id] [-n dev_name] [-u unit_number]
camcontrol tur [device id] [generic args]
camcontrol sense [device id] [generic args] [-D] [-x]
camcontrol inquiry [device id] [generic args] [-D] [-S] [-R]
camcontrol identify [device id] [generic args] [-v]
camcontrol reportluns [device id] [generic args] [-c] [-l]
           [-r reporttype]
camcontrol readcap [device id] [generic args] [-b] [-h] [-H] [-l] [-N]
           [-q] [-s]
camcontrol start [device id] [generic args]
camcontrol stop [device id] [generic args]
camcontrol load [device id] [generic args]
camcontrol eject [device id] [generic args]
camcontrol reprobe [device id]
camcontrol rescan โŸจall | device id | bus[:target:lun]โŸฉ
camcontrol reset โŸจall | device id | bus[:target:lun]โŸฉ
camcontrol defects [device id] [generic args] โŸจ-f formatโŸฉ [-P] [-G] [-q]
           [-s] [-S offset] [-X]
camcontrol modepage [device id] [generic args] [-6]
           โŸจ-m page[,subpage] | -lโŸฉ [-P pgctl] [-D] [-L] [-b | -e] [-d]
camcontrol cmd [device id] [generic args] โŸจ-a cmd [args]โŸฉ
           โŸจ-c cmd [args]โŸฉ [-d] [-f] [-i len fmt] [-o len fmt [args]]
           [-r fmt]
camcontrol smpcmd [device id] [generic args] โŸจ-r len fmt [args]โŸฉ
           โŸจ-R len fmt [args]โŸฉ
camcontrol smprg [device id] [generic args] [-l]
camcontrol smppc [device id] [generic args] โŸจ-p phyโŸฉ [-l] [-o operation]
           [-d name] [-m rate] [-M rate] [-T pp_timeout]
           [-a enable|disable] [-A enable|disable] [-s enable|disable]
           [-S enable|disable]
camcontrol smpphylist [device id] [generic args] [-l] [-q]
camcontrol smpmaninfo [device id] [generic args] [-l]
camcontrol debug [-I] [-P] [-T] [-S] [-X] [-c] [-p]
           โŸจall | off | device id | bus[:target[:lun]]โŸฉ
camcontrol tags [device id] [generic args] [-N tags] [-q] [-v]
camcontrol negotiate [device id] [generic args] [-c] [-D enable|disable]
           [-M mode] [-O offset] [-q] [-R syncrate] [-T enable|disable]
           [-U] [-W bus_width] [-v]
camcontrol format [device id] [generic args] [-q] [-r] [-w] [-y]
camcontrol sanitize [device id] [generic args]
           โŸจ-a overwrite | block | crypto | exitfailureโŸฉ [-c passes]
           [-I] [-P pattern] [-q] [-U] [-r] [-w] [-y]
camcontrol idle [device id] [generic args] [-t time]
camcontrol standby [device id] [generic args] [-t time]
camcontrol sleep [device id] [generic args]
camcontrol powermode [device id] [generic args]
camcontrol apm [device id] [generic args] [-l level]
camcontrol aam [device id] [generic args] [-l level]
camcontrol fwdownload [device id] [generic args] โŸจ-f fw_imageโŸฉ [-q] [-s]
           [-y]
camcontrol security [device id] [generic args] [-d pwd] [-e pwd] [-f]
           [-h pwd] [-k pwd] [-l high|maximum] [-q] [-s pwd]
           [-T timeout] [-U user|master] [-y]
camcontrol hpa [device id] [generic args] [-f] [-l] [-P] [-p pwd] [-q]
           [-s max_sectors] [-U pwd] [-y]
camcontrol ama [device id] [generic args] [-f] [-q] [-s max_sectors]
camcontrol persist [device id] [generic args] โŸจ-i action | -o actionโŸฉ
           [-a] [-I trans_id] [-k key] [-K sa_key] [-p]
           [-R rel_tgt_port] [-s scope] [-S] [-T res_type] [-U]
camcontrol attrib [device id] [generic args] โŸจ-r action | -w attribโŸฉ
           [-a attr_num] [-c] [-e elem_addr] [-F form1,form2] [-p part]
           [-s start_addr] [-T elem_type] [-V lv_num]
camcontrol opcodes [device id] [generic args] [-o opcode]
           [-s service_action] [-N] [-T]
camcontrol zone โŸจ-c cmdโŸฉ [-a] [-l lba] [-o rep_opts] [-P print_opts]
camcontrol epc โŸจ-c cmdโŸฉ [-d] [-D] [-e] [-H] [-p power_cond] [-P]
           [-r restore_src] [-s] [-S power_src] [-T timer]
camcontrol timestamp [device id] [generic args] โŸจ-r [-f format | -m |
           -U] | -s โŸจ-f format -T time | -UโŸฉโŸฉ
camcontrol devtype [device id]
camcontrol depop [device id] [generic args] โŸจ-l | -d | -rโŸฉ [-e elem]
           [-c capacity]
camcontrol help

๐ŸŒˆ DESCRIPTION ๐ŸŒˆ

Okay so the camcontrol utility allows users to access and control the FreeBSD CAM subsystem described in cam(4). It is iconic for people who need it, but it is also not a toy.

โš ๏ธ Real talk: camcontrol can cause a loss of data and/or system crashes if used improperly. Even expert users are encouraged to exercise caution when using this command. Novice users should stay away from this utility. ๐Ÿ˜ญ

The camcontrol utility has a number of primary functions, many of which support an optional device identifier. A device identifier can take one of three forms, iykyk:

  • deviceUNIT โ€” Specify a device name and unit number combination, like "da5" or "cd3". ๐Ÿ’–
  • bus:target โ€” Specify a bus number and target id. The bus number can be determined from the output of camcontrol devlist. The lun defaults to 0.
  • bus:target:lun โ€” Specify the bus, target and lun for a device. (e.g. 1:2:0)

If you do specify a device identifier, it must come immediately after the function name, and before any generic or function-specific arguments. Note that the -n and -u arguments described below will override any device name or unit number specified beforehand. The -n and -u arguments will not override a specified bus:target or bus:target:lun, however. That's the rule, periodt. ๐Ÿ’…

Most of the camcontrol primary functions support these generic arguments:

  • -C count โ€” SCSI command retry count. In order for this to work, error recovery (-E) must be turned on.
  • -E โ€” Instruct the kernel to perform generic SCSI error recovery for the given command. This is needed in order for the retry count (-C) to be honored. Other than retrying commands, the generic error recovery in the code will generally attempt to spin up drives that are not spinning. It may take some other actions, depending upon the sense code returned from the command.
  • -n dev_name โ€” Specify the device type to operate on, e.g. "da", "cd".
  • -Q task_attr โ€” SCSI task attribute for the command, if it is a SCSI command. This may be ordered, simple, head, or aca. In most cases this is not needed. The default is simple, which works with all SCSI devices. The task attribute may also be specified numerically.
  • -t timeout โ€” SCSI command timeout in seconds. This overrides the default timeout for any given command.
  • -u unit_number โ€” Specify the device unit number, e.g. "1", "5".
  • -v โ€” Be verbose, print out sense information for failed SCSI commands.

Primary command functions, incoming:

  • devlist โ€” List all physical devices (logical units) attached to the CAM subsystem. This also includes a list of peripheral drivers attached to each device. With the -v argument, SCSI bus number, adapter name and unit numbers are printed as well. On the other hand, with the -b argument, only the bus adapter, and unit information will be printed, and device information will be omitted. ๐Ÿฆ‹
  • periphlist โ€” List all peripheral drivers attached to a given physical device (logical unit).
  • tur โ€” Send the SCSI test unit ready (0x00) command to the given device. The camcontrol utility will report whether the device is ready or not.
  • sense โ€” Send a SCSI REQUEST SENSE command (0x03) to a device. The decoded sense (or hexdump) is printed to stdout.
    • -D โ€” Request descriptor sense instead of fixed sense.
    • -x โ€” Do a hexdump of the returned sense data.
  • inquiry โ€” Send a SCSI inquiry command (0x12) to a device. By default, camcontrol will print out the standard inquiry data, device serial number, and transfer rate information. The user can specify that only certain types of inquiry data be printed:
    • -D โ€” Get the standard inquiry data.
    • -S โ€” Print out the serial number. If this flag is the only one specified, camcontrol will not print out "Serial Number" before the value returned by the drive. This is to aid in script writing.
    • -R โ€” Print out transfer rate information.
  • identify โ€” Send an ATA identify command (0xec) to a device.
  • reportluns โ€” Send the SCSI REPORT LUNS (0xA0) command to the given device. By default, camcontrol will print out the list of logical units (LUNs) supported by the target device. There are a couple of options to modify the output:
    • -c โ€” Just print out a count of LUNs, not the actual LUN numbers.
    • -l โ€” Just print out the LUNs, and do not print out the count.
    • -r reporttype โ€” Specify the type of report to request from the target:
      • default โ€” Return the default report. This is the camcontrol default. Most targets will support this report if they support the REPORT LUNS command.
      • wellknown โ€” Return only well known LUNs.
      • all โ€” Return all available LUNs.

camcontrol will try to print out LUN numbers in a reasonable format. It can understand the peripheral, flat, LUN and extended LUN formats. โœจ

  • readcap โ€” Send the SCSI READ CAPACITY command to the given device and display the results. If the device is larger than 2TB, the SCSI READ CAPACITY (16) service action will be sent to obtain the full size of the device. By default, camcontrol will print out the last logical block of the device, and the blocksize of the device in bytes. To modify the output format, use the following options:
    • -b โ€” Just print out the blocksize, not the last block or device size. This cannot be used with -N or -s.
    • -h โ€” Print out the device size in human readable (base 2, 1K == 1024) format. This implies -N and cannot be used with -q or -b.

And the flags? Say less:

  • -H โ€” prints the device size in human readable (base 10, 1K == 1000) format. cute and legible, we love.
  • -l โ€” skips sending the SCSI READ CAPACITY (10) command. Sends only the SCSI READ CAPACITY (16) service action and reports its results. When the two do not match, a quirk is needed to resolve the ambiguity. messy but iconic.
  • -N โ€” prints the number of blocks in the device instead of the last logical block. block math bestie.
  • -q โ€” quiet mode: prints the numbers only (separated by a comma if -b or -s are not specified). no yapping.
  • -s โ€” prints the last logical block or the size of the device only, and omits the blocksize. just the main character number.
Note that this command only displays the information, it does not update the kernel data structures. Use the camcontrol reprobe subcommand to do that. no cap, display โ‰  refresh.

start

Sends the SCSI Start/Stop Unit (0x1B) command to the given device with the start bit set. spin that thing up, bestie.

stop

Sends the SCSI Start/Stop Unit (0x1B) command to the given device with the start bit cleared. power down era.

load

Sends the SCSI Start/Stop Unit (0x1B) command to the given device with the start bit set and the load/eject bit set. load it like you mean it.

eject

Sends the SCSI Start/Stop Unit (0x1B) command to the given device with the start bit cleared and the load/eject bit set. bye-bye media ๐Ÿ’…

rescan

Tells the kernel to scan all buses in the system (with the all argument), the given bus (XPT_SCAN_BUS), bus:target:lun or device (XPT_SCAN_LUN) for new devices or devices that have gone away. The user may specify a scan of all buses, a single bus, or a lun. Scanning all luns on a target is not supported.

If a device is specified by peripheral name and unit number, for instance da4, it may only be rescanned if that device currently exists in the CAM EDT (Existing Device Table). If the device is no longer there (see camcontrol devlist), you must use the bus:target:lun form to rescan it. iykyk, EDT is the guest list.

reprobe

Tells the kernel to refresh the information about the device and notify the upper layer, GEOM(4). This includes sending the SCSI READ CAPACITY command and updating the disk size visible to the rest of the system. glow-up for the kernelโ€™s view of the disk.

reset

Tells the kernel to reset all buses in the system (with the all argument), the given bus (XPT_RESET_BUS) by issuing a SCSI bus reset for that bus, or to reset the given bus:target:lun or device (XPT_RESET_DEV), typically by issuing a BUS DEVICE RESET message after connecting to that device.

Note that this can have a destructive impact on the system. like, actually destructive. handle with care, bestie.

defects

Sends the SCSI READ DEFECT DATA (10) command (0x37) or the SCSI READ DEFECT DATA (12) command (0xB7) to the given device, and prints out any combination of: the total number of defects, the primary defect list (PLIST), and the grown defect list (GLIST). bad-block lore dump.

  • -f format โ€” specifies the requested format of the defect list. The format argument is required. Most drives support the physical sector format. Some drives support the logical block format. Many drives, if they do not support the requested format, return the data in an alternate format, along with sense information indicating that the requested data format is not supported. The camcontrol utility attempts to detect this, and print out whatever format the drive returns. If the drive uses a non-standard sense code to report that it does not support the requested format, camcontrol will probably see the error as a failure to complete the request. drive said โ€œnot supportedโ€ but also sent data? messy.

The format options are:

  • block โ€” prints out the list as logical blocks. This is limited to 32-bit block sizes, and isnโ€™t supported by many modern drives.
  • longblock โ€” prints out the list as logical blocks. This option uses a 64-bit block size.
  • bfi โ€” prints out the list in bytes from index format.
  • extbfi โ€” prints out the list in extended bytes from index format. The extended format allows for ranges of blocks to be printed.
  • phys โ€” prints out the list in physical sector format. Most drives support this format.
  • extphys โ€” prints out the list in extended physical sector format. The extended format allows for ranges of blocks to be printed.
  • -G โ€” prints out the grown defect list. This is a list of bad blocks that have been remapped since the disk left the factory. post-factory plot twists.
  • -P โ€” prints out the primary defect list. This is the list of defects that were present in the factory. factory-original chaos.
  • -q โ€” when printing status information with -s, only prints the number of defects. no extra commentary.
  • -s โ€” just prints the number of defects, not the list of defects. count only, list is not invited.
  • -S offset โ€” specifies the starting offset into the defect list. This implies using the SCSI READ DEFECT DATA (12) command, as the 10 byte version of the command doesnโ€™t support the address descriptor index field. Not all drives support the 12 byte command, and some drives that support the 12 byte command donโ€™t support the address descriptor index field. feature support is a vibe check, fr fr.
  • -X โ€” prints out defects in hexadecimal (base 16) form instead of base 10 form.

If neither -P nor -G is specified, camcontrol will print out the number of defects given in the READ DEFECT DATA header returned from the drive. Some drives will report 0 defects if neither the primary or grown defect lists are requested. some drives are lowkey dramatic like that.

modepage

Allows the user to display and optionally edit a SCSI mode page. The mode page formats are located in /usr/share/misc/scsi_modes. This can be overridden by specifying a different file in the SCSI_MODES environment variable. The modepage command takes several arguments:

  • -6 โ€” use 6 byte MODE commands instead of default 10 byte. Old devices may not support 10 byte MODE commands, while new devices may not be able to report all mode pages with 6 byte commands. If not specified, camcontrol starts with 10 byte commands and falls back to 6 byte on error. default is 10, fallback is 6, we contain multitudes.
  • -d โ€” disables block descriptors for mode sense.
  • -D โ€” displays/edits block descriptors instead of mode page. descriptor main character arc.
  • -L โ€” use long LBA block descriptors. Allows number of LBAs bigger than 2^^32. big-number slay.
  • -b โ€” displays mode page data in binary format. raw binary bestie.
  • -e โ€” this flag allows the user to edit values in the mode page. The user may either edit mode page values with the text editor pointed to by his EDITOR environment variable, or supply mode page values via standard input, using the same format that camcontrol uses to display mode page values. The editor will be invoked if camcontrol detects that standard input is terminal. editing era, be careful.
  • -l โ€” lists all available mode pages. If specified more than once, also lists subpages. double -l? subpage lore unlocked.
  • -m page[,subpage] โ€” specifies the number of the mode page and optionally subpage the user would like to view and/or edit. This argument is mandatory unless -l is specified. required unless youโ€™re just listing, periodt.
  • -P pgctl โ€” this allows the user to specify the page control field. Possible values are:
    • 0 โ€” Current values
    • 1 โ€” Changeable values
    • 2 โ€” Default values
    • 3 โ€” Saved values

cmd

Allows the user to send an arbitrary ATA or SCSI CDB to any device. The cmd function requires the -c argument to specify SCSI CDB or the -a argument to specify ATA Command Block registers values. Other arguments are optional, depending on the command type. The command and data specification syntax is documented in cam_cdbparse(3).

NOTE: If the CDB specified causes data to be transferred to or from the SCSI device in question, you MUST specify either -i or -o. like, MUST MUST. no skipping.
  • -a cmd [args] โ€” this specifies the content of 12 ATA Command Block registers (command, features, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp. lba_high_exp, features_exp, sector_count, sector_count_exp). yes, that period is living there, we donโ€™t touch it.
  • -c cmd [args] โ€” this specifies the SCSI CDB. SCSI CDBs may be 6, 10, 12 or 16 bytes. CDB sizes are giving range.
  • -d โ€” says "use the DMA protocol for this ATA command, bestie." that's the whole assignment.
  • -f โ€” same energy but for the FPDMA (NCQ) protocol. fancy queueing behavior, we love her.
  • -i len fmt โ€” controls how much data gets read and how it gets shown to you. and if fmt is -, then len bytes get read off the device and dumped straight to standard output. raw data, no filter, main character delivery.
  • -o len fmt [args] โ€” the write girlies' version: how much data goes to the device, plus the actual data itself. if fmt is -, len bytes come in from standard input and get written to the device. stdin to device pipeline, iconic.
  • -r fmt โ€” tells it to display the 11 result ATA Command Block registers, and how to display them: status, error, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp, lba_high_exp, sector_count, sector_count_exp. yes, all eleven, we're not skipping any. and if fmt is -, those 11 result registers get written to standard output in hex. ๐Ÿงฎ

smpcmd

okay so smpcmd lets you send an arbitrary Serial Management Protocol (SMP) command to a device. it's the "I'll do it myself" option. ๐Ÿ’…

it needs two things: the -r argument to specify the SMP request being sent, and the -R argument to specify the format of the SMP response. the syntax for both of those arguments is documented over in cam_cdbparse(3) โ€” go read that, iykyk.

โš ๏ธ real talk: SAS adapters that support SMP passthrough (at least the ones currently known) do not accept CRC bytes from the user in the request, and they don't pass CRC bytes back to you in the response either. so bestie: don't include the CRC bytes in the length of your request, and don't sit there expecting CRC bytes in the response. they're not coming. ๐Ÿ˜ญ
  • -r len fmt [args] โ€” sets the size of the SMP request, without the CRC bytes, plus the SMP request format. if fmt is -, len bytes get read from standard input and sent as the SMP request. ๐Ÿซถ
  • -R len fmt [args] โ€” sets the size of the buffer allocated for the SMP response, plus the SMP response format. if fmt is -, len bytes get allocated for the response and the response gets written to standard output.

smprg

smprg sends the Serial Management Protocol (SMP) Report General command to a device. camcontrol then displays the data the Report General command handed back. and if the SMP target supports the long response format, the extra data gets requested and displayed automatically โ€” no extra work from you, we love a self-sufficient icon. โœจ

  • -l โ€” request the long response format only. heads up though: not every SMP target supports the long response format. this option makes camcontrol skip sending the initial report general request without the long bit set, and only issue a report general request with the long bit set. committing to the long life, no trial run.

smppc

smppc lets you issue the Serial Management Protocol (SMP) PHY Control command to a device.

๐Ÿšจ use this one with some caution, okay? it can render devices inaccessible, and it could potentially cause data corruption too. this is not a drill, this is not a vibe, this is a "please know what you're doing" situation.

the -p argument is required to specify the PHY you're operating on. no phy, no service. ๐Ÿ™ˆ

  • -p phy โ€” specify the PHY to operate on. this argument is required. (yes, again. it's that serious.)
  • -l โ€” request the long request/response format. not all SMP targets support the long response format. for the PHY Control command specifically, this currently only affects whether the request length is set to a value other than 0.
  • -o operation โ€” specify a PHY control operation. only one -o operation may be specified. the operation can be given numerically (decimal, hexadecimal, or octal) or as one of these names:
    • nop โ€” No operation. honestly it's not even necessary to specify this argument.
    • linkreset โ€” Send the LINK RESET command to the phy.
    • hardreset โ€” Send the HARD RESET command to the phy.
    • disable โ€” Send the DISABLE command to the phy. note that the LINK RESET or HARD RESET commands should re-enable the phy. ๐Ÿ”
    • clearerrlog โ€” Send the CLEAR ERROR LOG command. this clears the error log counters for the specified phy.
    • clearaffiliation โ€” Send the CLEAR AFFILIATION command. this clears the affiliation from the STP initiator port with the same SAS address as the SMP initiator that requests the clear operation.
    • sataportsel โ€” Send the TRANSMIT SATA PORT SELECTION SIGNAL command to the phy. this will cause a SATA port selector to use the given phy as its active phy and make the other phy inactive. ๐Ÿ’ซ
    • clearitnl โ€” Send the CLEAR STP I_T NEXUS LOSS command to the PHY.
    • setdevname โ€” Send the SET ATTACHED DEVICE NAME command to the PHY. this one requires the -d argument to specify the device name.
  • -d name โ€” specify the attached device name. needed when you're using the -o setdevname phy operation. the name is a 64-bit number, and you can write it in decimal, hexadecimal or octal format. ๐ŸŽ€
  • -m rate โ€” set the minimum physical link rate for the phy. numeric argument. the currently known link rates are:
    • 0x0 โ€” Do not change current value.
    • 0x8 โ€” 1.5 Gbps
    • 0x9 โ€” 3 Gbps
    • 0xa โ€” 6 Gbps

other values may be specified for newer physical link rates. ๐Ÿ‘‘

  • -M rate โ€” set the maximum physical link rate for the phy. numeric argument. see the -m argument description above for the known link rate values.
  • -T pp_timeout โ€” set the partial pathway timeout value, in microseconds. see the ANSI SAS Protocol Layer (SPL) specification if you want the full lore on this field.
  • -a enable|disable โ€” enable or disable SATA slumber phy power conditions. ๐Ÿ˜ด
  • -A enable|disable โ€” enable or disable SATA partial power conditions.
  • -s enable|disable โ€” enable or disable SAS slumber phy power conditions.
  • -S enable|disable โ€” enable or disable SAS partial phy power conditions.

smpphylist

smpphylist lists the phys attached to a SAS expander, the address of the end device attached to the phy, and the inquiry data for that device plus any peripheral devices attached to it. the inquiry data and the peripheral devices only show up if they're available โ€” so if it's quiet, it's not being shady, the info just isn't there. ๐ŸŒธ

  • -l โ€” turn on the long response format for the underlying SMP commands this command uses.
  • -q โ€” only print out phys that are attached to a device in the CAM EDT (Existing Device Table). filtering, but make it fashion. ๐Ÿ’…

smpmaninfo

smpmaninfo sends the SMP Report Manufacturer Information command to the device and displays the response. manufacturer lore, delivered. ๐Ÿญ

  • -l โ€” turn on the long response format for the underlying SMP commands this command uses.

๐Ÿ› debug โ€” for when you wanna see EVERYTHING

This one flips on CAM debugging printfs in the kernel. Heads up though: it needs options CAMDEBUG in your kernel config file or it's a no-go.

โš ๏ธ WARNING, bestie, fr fr: turning on debugging printfs currently causes an EXTREME number of kernel printfs. Like, extreme extreme. You may have genuine difficulty turning the debugging printfs off once they start, because the kernel will be busy printing messages and unable to service other requests quickly. It's giving "opened pandora's box at 3am" energy. ๐Ÿ˜ญ๐Ÿ’€

The debug function takes a bunch of arguments:

  • -I โ€” enables CAM_DEBUG_INFO printfs.
  • -P โ€” enables CAM_DEBUG_PERIPH printfs.
  • -T โ€” enables CAM_DEBUG_TRACE printfs.
  • -S โ€” enables CAM_DEBUG_SUBTRACE printfs.
  • -X โ€” enables CAM_DEBUG_XPT printfs.
  • -c โ€” enables CAM_DEBUG_CDB printfs. This will cause the kernel to print out the SCSI CDBs sent to the specified device(s).
  • -p โ€” enables CAM_DEBUG_PROBE printfs.
  • all โ€” enables debugging for all devices.
  • off โ€” turns off debugging for all devices.
  • bus[:target[:lun]] โ€” turns on debugging for the given bus, target or lun. If the lun, or the target and lun, aren't specified, they get wildcarded. (So like, just specifying a bus turns on debugging printfs for all devices on that bus. Slay.)

๐Ÿท๏ธ tags โ€” tagged openings, aka the queue capacity vibe check

Shows or sets the number of "tagged openings" โ€” that's the simultaneous transactions we attempt to queue to a particular device. By default, the tags command with no command-specific arguments (i.e. only generic arguments) prints out the "soft" maximum number of transactions that can be queued to the device in question. Want the detailed tea? Use the -v argument described below. โœจ

  • -N tags โ€” set the number of tags for the given device. This must be between the minimum and maximum number set in the kernel quirk table. The default for most devices that support tagged queueing is a minimum of 2 and a maximum of 255. The minimum and maximum values for a given device may be determined by using the -v switch โ€” its meaning for this camcontrol subcommand is described below.
  • -q โ€” be quiet, and don't report the number of tags. This is generally used when setting the number of tags.
  • -v โ€” the verbose flag has special functionality for the tags argument. It causes camcontrol to print out the tagged queueing related fields of the XPT_GDEV_TYPE CCB:
    • dev_openings โ€” this is the amount of capacity for transactions queued to a given device.
    • dev_active โ€” this is the number of transactions currently queued to a device.
    • allocated โ€” this is the number of CCBs allocated for the device.
    • held โ€” the held count is the number of CCBs held by peripheral drivers that have either just been completed or are about to be released to the transport layer for service by a device. Held CCBs reserve capacity on a given device.
    • mintags โ€” this is the current "hard" minimum number of transactions that can be queued to a device at once. The dev_openings value above cannot go below this number. The default value for mintags is 2, although it may be set higher or lower for various devices.
    • maxtags โ€” this is the "hard" maximum number of transactions that can be queued to a device at one time. The dev_openings value cannot go above this number. The default value for maxtags is 255, although it may be set higher or lower for various devices.

๐Ÿค negotiate โ€” communication parameters, let's talk about it

Shows or negotiates various communication parameters. Here's the thing though โ€” some controllers may not support setting or changing some of these values. For instance, the Adaptec 174x controllers do not support changing a device's sync rate or offset. The camcontrol utility won't attempt to set the parameter if the controller indicates that it does not support setting the parameter. To find out what the controller supports, use the -v flag โ€” its meaning for the negotiate command is described below. Also, some controller drivers don't support setting negotiation parameters, even if the underlying controller supports negotiation changes. Some controllers, such as the Advansys wide controllers, support enabling and disabling synchronous negotiation for a device, but do not support setting the synchronous negotiation rate. ๐Ÿ™ˆ

  • -a โ€” attempt to make the negotiation settings take effect immediately by sending a Test Unit Ready command to the device.
  • -c โ€” show or set current negotiation settings. This is the default.
  • -D enable|disable โ€” enable or disable disconnection.
  • -M mode โ€” set ATA mode.
  • -O offset โ€” set the command delay offset.
  • -q โ€” be quiet, do not print anything. This is generally useful when you want to set a parameter, but do not want any status information.
  • -R syncrate โ€” change the synchronization rate for a device. The sync rate is a floating point value specified in MHz. So, for instance, 20.000 is a legal value, as is 20.
  • -T enable|disable โ€” enable or disable tagged queueing for a device.
  • -U โ€” show or set user negotiation settings. The default is to show or set current negotiation settings.
  • -v โ€” the verbose switch has special meaning for the negotiate subcommand. It causes camcontrol to print out the contents of a Path Inquiry (XPT_PATH_INQ) CCB sent to the controller driver.
  • -W bus_width โ€” specify the bus width to negotiate with a device. The bus width is specified in bits. The only useful values to specify are 8, 16, and 32 bits. The controller must support the bus width in question in order for the setting to take effect.

In general, sync rate and offset settings will not take effect for a device until a command has been sent to the device. The -a switch above will automatically send a Test Unit Ready to the device so negotiation parameters will take effect. ๐Ÿซถ


๐Ÿ’ฟ format โ€” SCSI FORMAT UNIT, proceed with fear

Issues the SCSI FORMAT UNIT command to the named device.

๐Ÿšจ WARNING! WARNING! WARNING! ๐Ÿšจ Low level formatting a disk will destroy ALL data on the disk. Use extreme caution when issuing this command. Not me watching people low-level format disks that do not really need to be low-level formatted... ๐Ÿ˜ญ There are relatively few scenarios that call for low-level formatting a disk. One reason for low-level formatting a disk is to initialize the disk after changing its physical sector size. Another reason for low-level formatting a disk is to revive the disk if you're getting "medium format corrupted" errors from the disk in response to read and write requests.

Some disks take longer than others to format. Users should specify a timeout long enough to allow the format to complete. The default format timeout is 3 hours, which should be long enough for most disks. Some hard disks will complete a format operation in a very short period of time (on the order of 5 minutes or less). This is often because the drive doesn't really support the FORMAT UNIT command โ€” it just accepts the command, waits a few minutes and then returns it. ๐Ÿ’€

The format subcommand takes several arguments that modify its default behavior. The -q and -y arguments can be useful for scripts.

  • -q โ€” be quiet, do not print any status messages. This option will not disable the questions, however. To disable questions, use the -y argument, below.
  • -r โ€” run in "report only" mode. This will report status on a format that is already running on the drive.
  • -w โ€” this one flips the format into non-immediate mode. By default, camcontrol fires off the FORMAT UNIT command with the immediate bit set โ€” which basically tells the device "yeah yeah, go do your thing, don't wait up," so it returns before the format is actually done. Then camcontrol pings the device for SCSI sense info every second to figure out how far along the format is. But if you pass -w, camcontrol issues a non-immediate format command instead โ€” and heads up, that means it will be unable to print anything letting you know what percentage of the disk has been formatted. You're flying blind, bestie. ๐Ÿ™ˆ
  • -y โ€” no questions, no vibes, just vibes-free execution. By default camcontrol will ask you if you really wanna format the disk in question, and also whether the default format command timeout is acceptable. The timeout question gets skipped if you already specified a timeout on the command line. โœจ

๐Ÿงผ sanitize ๐Ÿงผ

Issue the SANITIZE command to the named device.

WARNING! WARNING! WARNING! ALL data on the disk will be destroyed or made inaccessible. Recovery of the data is not possible. Use extreme caution when issuing this command. ๐Ÿ’€

The โ€˜sanitizeโ€™ subcommand takes several arguments that modify its default behavior. The -q and -y arguments can be useful for scripts. ๐Ÿซถ

  • -a operation โ€” specify the sanitize operation to perform. Options are:
    • overwrite โ€” perform an overwrite operation by writing a user supplied data pattern to the device one or more times. The pattern is given by the -P argument. The number of times is given by the -c argument. ๐Ÿ”
    • block โ€” perform a block erase operation. All the device's blocks are set to a vendor defined value, typically zero. ๐Ÿงฑ
    • crypto โ€” perform a cryptographic erase operation. The encryption keys are changed to prevent the decryption of the data. ๐Ÿ”‘
    • exitfailure โ€” exits a previously failed sanitize operation. A failed sanitize operation can only be exited if it was run in the unrestricted completion mode, as provided by the -U argument. ๐Ÿšช
  • -c passes โ€” the number of passes when performing an โ€˜overwriteโ€™ operation. Valid values are between 1 and 31. The default is 1. โญ
  • -I โ€” when performing an โ€˜overwriteโ€™ operation, the pattern is inverted between consecutive passes. ๐Ÿ™ƒ
  • -P pattern โ€” path to the file containing the pattern to use when performing an โ€˜overwriteโ€™ operation. The pattern is repeated as needed to fill each block. ๐ŸŽ€
  • -q โ€” be quiet, do not print any status messages. This option will not disable the questions, however. To disable questions, use the -y argument, below. ๐Ÿคซ
  • -U โ€” perform the sanitize in the unrestricted completion mode. If the operation fails, it can later be exited with the โ€˜exitfailureโ€™ operation. ๐Ÿฆ‹
  • -r โ€” run in โ€œreport onlyโ€ mode. This will report status on a sanitize that is already running on the drive. ๐Ÿ‘€
  • -w โ€” issue a non-immediate sanitize command. By default, camcontrol issues the SANITIZE command with the immediate bit set. This tells the device to immediately return the sanitize command, before the sanitize has actually completed. Then, camcontrol gathers SCSI sense information from the device every second to determine how far along in the sanitize process it is. If the -w argument is specified, camcontrol will issue a non-immediate sanitize command, and will be unable to print any information to let the user know what percentage of the disk has been sanitized. ๐Ÿ˜ญ
  • -y โ€” do not ask any questions. By default, camcontrol will ask the user if he/she really wants to sanitize the disk in question, and also if the default sanitize command timeout is acceptable. The user will not be asked about the timeout if a timeout is specified on the command line. ๐Ÿ’…

๐Ÿ˜ด idle ๐Ÿ˜ด

Put ATA device into IDLE state. Optional parameter (-t) specifies automatic standby timer value in seconds. Value 0 disables timer. โฒ๏ธ

๐Ÿ›Œ standby ๐Ÿ›Œ

Put ATA device into STANDBY state. Optional parameter (-t) specifies automatic standby timer value in seconds. Value 0 disables timer. ๐Ÿ’ค

๐ŸŒ™ sleep ๐ŸŒ™

Put ATA device into SLEEP state. Note that the only way get device out of this state may be reset. ๐Ÿ˜ตโ€๐Ÿ’ซ (yes literally, a reset โ€” that's the exit strategy)

๐Ÿ”Œ powermode ๐Ÿ”Œ

Report ATA device power mode. ๐Ÿ“Š

โšก apm โšก

If optional parameter (-l) specified, enables and sets advanced power management level, where:

  • 1 โ€” minimum power
  • 127 โ€” maximum performance with standby
  • 128 โ€” minimum power without standby
  • 254 โ€” maximum performance

If not specified โ€” APM is disabled. ๐Ÿ”‹

๐Ÿ”Š aam ๐Ÿ”Š

If optional parameter (-l) specified, enables and sets automatic acoustic management level, where:

  • 1 โ€” minimum noise
  • 254 โ€” maximum performance

If not specified โ€” AAM is disabled. ๐Ÿคซ

๐Ÿ” security ๐Ÿ”

Update or report security settings, using an ATA identify command (0xec). By default, camcontrol will print out the security support and associated settings of the device. The security command takes several arguments:

  • -d pwd โ€” disable device security using the given password for the selected user according to the devices configured security level.
  • -e pwd โ€” erase the device using the given password for the selected user.
WARNING! WARNING! WARNING! Issuing a secure erase will ERASE ALL user data on the device and may take several hours to complete. ๐Ÿ’€

When this command is used against an SSD drive all its cells will be marked as empty, restoring it to factory default write performance. For SSD's this action usually takes just a few seconds. โšก

  • -f โ€” freeze the security configuration of the specified device.

After command completion any other commands that update the device lock mode shall be command aborted. Frozen mode is disabled by power-off or hardware reset. ๐ŸงŠ

  • -h pwd โ€” enhanced erase the device using the given password for the selected user.
WARNING! WARNING! WARNING! Issuing an enhanced secure erase will ERASE ALL user data on the device and may take several hours to complete. ๐Ÿ’€

An enhanced erase writes predetermined data patterns to all user data areas, all previously written user data shall be overwritten, including sectors that are no longer in use due to reallocation. ๐Ÿงน

  • -k pwd โ€” unlock the device using the given password for the selected user according to the devices configured security level. ๐Ÿ”“
  • -l high|maximum โ€” specifies which security level to set when issuing a -s pwd command. The security level determines device behavior when the master password is used to unlock the device. When the security level is set to high the device requires the unlock command and the master password to unlock. When the security level is set to maximum the device requires a secure erase with the master password to unlock. ๐Ÿ”ฅ

This option must be used in conjunction with one of the security action commands. โš ๏ธ

Defaults to high.

  • -q โ€” be quiet, do not print any status messages. This option will not disable the questions, however. To disable questions, use the -y argument, below. ๐Ÿคซ
  • -s pwd โ€” password the device (enable security) using the given password for the selected user. This option can be combined with other options such as -e pwd. ๐ŸŽ€

A master password may be set in a addition to the user password. The purpose of the master password is to allow an administrator to establish a password that is kept secret from the user, and which may be used to unlock the device if the user password is lost. ๐Ÿ‘‘

Note: Setting the master password does not enable device security. ๐Ÿ“

If the master password is set and the drive supports a Master Revision Code feature the Master Password Revision Code will be decremented. ๐Ÿ”ฝ

  • -T timeout โ€” overrides the default timeout, specified in seconds, used for both -e and -h this is useful if your system has problems processing long timeouts correctly. โฑ๏ธ

Usually the timeout is calculated from the information stored on the drive if present, otherwise it defaults to 2 hours.

  • -U user|master โ€” takes either user or master. ๐ŸŒธ
  • -u user โ€” tells it which user to set/use for the action command you're running. Valid values are literally just user or master, and if you don't set it, it defaults to master. You have to pair this with one of the security action commands, okay? Not optional-optional. Defaults to master.
  • -y โ€” confirm yes to the dangerous stuff (think -e and friends) without it stopping to ask you "are you sure?" first.
Heads up bestie ๐Ÿ’– โ€” if the password you gave for any of the action commands doesn't match the password configured for the user you named, the command just fails. No drama, no retry, it's done. And for real, the password is capped at 32 characters in all cases. Longer than that and it fails. Periodt.

๐ŸŽ€ hpa โ€” Host Protected Area vibes

Update or report Host Protected Area details. By default, camcontrol prints out the HPA support and the associated settings of the device โ€” like a little status report card. The hpa command takes several optional arguments:

  • -f โ€” freeze the HPA configuration of the specified device. After the command completes, any other commands that try to update the HPA configuration get command aborted. Frozen mode is disabled by power-off or hardware reset. ๐ŸงŠ
  • -l โ€” lock the HPA configuration of the device until a successful call to unlock, or the next power-on reset happens. Whichever comes first, bestie.
  • -P โ€” make the HPA max sectors persist across a power-on reset or a hardware reset. You must use this in combination with -s max_sectors.
  • -p pwd โ€” set the HPA configuration password required for unlock calls.
  • -q โ€” be quiet, don't print any status messages. Important: this does not disable the questions ๐Ÿ‘€. If you want the questions gone too, use the -y argument below.
  • -s max_sectors โ€” configures the maximum user accessible sectors of the device. This changes the number of sectors the device reports.
โš ๏ธ WARNING! WARNING! WARNING! โš ๏ธ Changing the max sectors of a device with this option makes the data on the device beyond the specified value inaccessible. Like, gone-gone. ๐Ÿ˜ญ Also: only one successful -s max_sectors call can be made without a power-on reset or a hardware reset of the device.
  • -U pwd โ€” unlock the HPA configuration of the specified device using the given password. If the password you specified doesn't match the password configured via -p pwd, the command fails.

And after 5 failed unlock calls due to password miss-match, the device will refuse additional unlock calls until after a power-on reset. It's literally holding a grudge ๐Ÿ’€.

  • -y โ€” confirm yes to dangerous options such as -e without prompting for confirmation.
The password for all HPA commands is limited to 32 characters โ€” longer passwords will fail.

๐ŸŒธ ama โ€” Accessible Max Address Configuration

Update or report Accessible Max Address Configuration. By default, camcontrol prints out the Accessible Max Address Configuration support and associated settings of the device. The ama command takes several optional arguments:

  • -f โ€” freeze the Accessible Max Address Configuration of the specified device. After command completion, any other commands that update the configuration get command aborted. Frozen mode is disabled by power-off.
  • -q โ€” be quiet, do not print any status messages. ๐Ÿคซ
  • -s max_sectors โ€” configures the maximum user accessible sectors of the device. This changes the number of sectors the device reports.
โš ๏ธ WARNING! WARNING! WARNING! โš ๏ธ Changing the max sectors of a device with this option makes the data on the device beyond the specified value indeterminate. Not "safe", not "fine" โ€” indeterminate. Do not play with this on a drive you care about ๐Ÿซถ And same rule as before: only one successful -s max_sectors call can be made without a power-on reset of the device.

๐Ÿ”ฅ fwdownload โ€” glow-up time for your firmware

Program the firmware of the named SCSI or ATA device using the image file you provide. It's giving "makeover episode" โœจ

If the device is a SCSI device and it provides a recommended timeout for the WRITE BUFFER command (peep the camcontrol opcodes subcommand for that), that timeout gets used for the firmware download. The drive-recommended timeout value can be overridden on the command line with the -t option.

Current list of supported vendors for SCSI/SAS drives:

  • HGST โ€” tested with 4TB SAS drives, model number HUS724040ALS640.
  • HITACHI
  • HP
  • IBM โ€” tested with LTO-5 (ULTRIUM-HH5) and LTO-6 (ULTRIUM-HH6) tape drives. There's a separate table entry for hard drives, because the update method for hard drives is different than the method for tape drives.
  • PLEXTOR
  • QUALSTAR
  • QUANTUM
  • SAMSUNG โ€” tested with SM1625 SSDs.
  • SEAGATE โ€” tested with Constellation ES (ST32000444SS), ES.2 (ST33000651SS) and ES.3 (ST1000NM0023) drives.
  • SmrtStor โ€” tested with 400GB Optimus SSDs (TXA2D20400GA6001).
  • TOSHIBA โ€” tested with 22TB MG10SFA22TE SAS drives.
โš ๏ธ WARNING! WARNING! WARNING! โš ๏ธ Little testing has been done to make sure that different device models from each vendor work correctly with the fwdownload command. A vendor name appearing in the supported list means only that firmware of at least one device type from that vendor has successfully been programmed with the fwdownload command. Extra caution should be taken when using this command, since there is no guarantee it will not break a device from the listed vendors. Ensure you have a recent backup of the data on the device before performing a firmware update. Like, please. For me. ๐Ÿ™

Note that unknown SCSI protocol devices will not be programmed, since there's little chance of the firmware download succeeding.

camcontrol will currently attempt a firmware download to any ATA or SATA device, since the standard ATA DOWNLOAD MICROCODE command may work. Firmware downloads to ATA and SATA devices are supported for devices connected to standard ATA and SATA controllers, and devices connected to SAS controllers with SCSI to ATA translation capability. In that latter case, camcontrol uses the SCSI ATA PASS-THROUGH command to send the ATA DOWNLOAD MICROCODE command to the drive. Some SCSI to ATA translation implementations don't work fully when translating SCSI WRITE BUFFER commands to ATA DOWNLOAD MICROCODE commands, but do support ATA passthrough well enough to do a firmware download. Translating is hard, okay? ๐Ÿ˜…

  • -f fw_image โ€” path to the firmware image file to be downloaded to the specified device.
  • -q โ€” do not print informational messages, only print errors. This option should be used with the -y option to suppress all output.
  • -s โ€” run in simulation mode. Device checks are run and the confirmation dialog is shown, but no firmware download will occur. Bestie's dress rehearsal ๐Ÿ’…
  • -v โ€” show SCSI or ATA errors in the event of a failure.

In simulation mode, print out the SCSI CDB or ATA register values that would be used for the firmware download command.

  • -y โ€” do not ask for confirmation.

๐Ÿ‘‘ persist โ€” persistent reservation support

Persistent reservations are a way to reserve a particular SCSI LUN for use by one or more SCSI initiators. If the -i option is specified, camcontrol issues the SCSI PERSISTENT RESERVE IN command using the requested service action. If the -o option is specified, camcontrol issues the SCSI PERSISTENT RESERVE OUT command using the requested service action. One of those two options is required โ€” pick a lane.

Persistent reservations are complex, and fully explaining them is outside the scope of this manual. Please visit https://www.t10.org and download the latest SPC spec for a full explanation of persistent reservations. (Yes, homework. Sorry. ๐ŸŽ€)

  • -i mode โ€” specify the service action for the PERSISTENT RESERVE IN command. Supported service actions:
    • read_keys โ€” report the current persistent reservation generation (PRgeneration) and any registered keys.
    • read_reservation โ€” report the persistent reservation, if any.
    • report_capabilities โ€” report the persistent reservation capabilities of the LUN.
    • read_full_status โ€” report the full status of persistent reservations on the LUN.
  • -o mode โ€” specify the service action for the PERSISTENT RESERVE OUT command. For service actions like register that are components of other service action names, the entire name must be specified. Otherwise, enough of the service action name must be specified to distinguish it from other possible service actions. Supported service actions:

okay so picking right back up with the service actions, bestie โ€” these are the actual moves you're asking for ๐Ÿ”ฅ

  • register โ€” registers a reservation key with the LUN, or unregisters one, depending on the vibe you're going for. To register a key: hand over the key you want as the Service Action Reservation Key. To unregister a key: give the previously registered key as the Reservation Key. To change a key: give the old key as the Reservation Key and the new one as the Service Action Reservation Key. That's the whole little switcheroo โœจ
  • register_ignore โ€” same energy as register, except the Reservation Key gets completely ignored ๐Ÿ‘€. The Service Action Reservation Key just steamrolls any previous key registered for the initiator. no thoughts, head empty, key overwritten ๐Ÿ’…
  • reserve โ€” creates a reservation. Important: a key has to be registered with the LUN before the LUN can be reserved, and you must pass it as the Reservation Key. You also have to specify the type of reservation. The scope defaults to LUN scope (LU_SCOPE), but you can change it if you want.
  • release โ€” releases a reservation. The Reservation Key must be specified. non-negotiable ๐Ÿซถ
  • clear โ€” releases a reservation and removes all the keys from the device. The Reservation Key must be specified.
  • preempt โ€” removes a reservation that belongs to another initiator ๐Ÿ˜ˆ. The Reservation Key must be specified. The Service Action Reservation Key may be specified too, depending on the operation being performed.
  • preempt_abort โ€” removes a reservation belonging to another initiator and aborts all outstanding commands from that initiator. The Reservation Key must be specified, and the Service Action Reservation Key may be specified depending on the operation being performed.
  • register_move โ€” registers another initiator with the LUN and establishes a reservation on the LUN for that initiator. Both the Reservation Key and the Service Action Reservation Key must be specified. you're basically matchmaking here ๐Ÿ’–
  • replace_lost โ€” replaces Lost Reservation information. that's it, that's the whole thing.

  • -a โ€” sets the All Target Ports (ALL_TG_PT) bit. This asks that the key registration be applied to all target ports, not just the particular target port that receives the command. Only applies to the register and register_ignore actions. โญ
  • -I tid โ€” specifies a Transport ID. This only applies to the Register and Register and Move service actions for Persistent Reserve Out. You can specify multiple Transport IDs with multiple -I arguments. With the Register service action, specifying one or more Transport IDs implicitly enables the -S option, which turns on the SPEC_I_PT bit. Transport IDs generally have the format protocol,id.

SAS ๐Ÿฆ‹

A SAS Transport ID is sas, followed by a 64-bit SAS address. Like this:

sas,0x1234567812345678

FC

A Fibre Channel Transport ID is fcp, followed by a 64-bit Fibre Channel World Wide Name. For example:

fcp,0x1234567812345678

SPI

A Parallel SCSI address is spi, followed by a SCSI target ID and a relative target port identifier. Example:

spi,4,1

1394

An IEEE 1394 (Firewire) Transport ID is sbp, followed by a 64-bit EUI-64 IEEE 1394 node unique identifier. like:

sbp,0x1234567812345678

RDMA

A SCSI over RDMA Transport ID is srp, followed by a 128-bit RDMA initiator port identifier. Heads up: the port identifier must be exactly 32 or 34 (if the leading 0x is included) hexadecimal digits. Only hexadecimal (base 16) numbers are supported โ€” no decimal nonsense here ๐Ÿ™ˆ. Example:

srp,0x12345678123456781234567812345678

iSCSI

An iSCSI Transport ID consists of an iSCSI name, and optionally a separator and iSCSI session ID. If only the iSCSI name is specified:

iqn.2012-06.com.example:target0

And if the iSCSI separator and initiator session ID are specified:

iqn.2012-06.com.example:target0,i,0x123

PCIe

A SCSI over PCIe Transport ID is sop, followed by a PCIe Routing ID. The Routing ID consists of a bus, device and function โ€” or, in the alternate form, a bus and function. The bus must be in the range of 0 to 255 inclusive, and the device must be in the range of 0 to 31 inclusive. The function must be in the range of 0 to 7 inclusive if the standard form is used, and in the range of 0 to 255 inclusive if the alternate form is used. If a bus, device and function are specified for the standard Routing ID form:

sop,4,5,1

And if the alternate Routing ID form is used:

sop,4,1
  • -k key โ€” specifies the Reservation Key. This may be in decimal, octal or hexadecimal format. The value defaults to zero if not otherwise specified. It must be between 0 and 2^64 - 1, inclusive. ๐ŸŽ€
  • -K key โ€” specifies the Service Action Reservation Key. Also decimal, octal or hexadecimal format, also zero by default if you don't say otherwise, and also has to be between 0 and 2^64 - 1, inclusive.
  • -p โ€” enables the Activate Persist Through Power Loss bit. Only used for the register and register_ignore actions. This requests that the reservation persist across power loss events. your reservation survives the blackout, iconic behavior ๐Ÿ’€โœจ
  • -s scope โ€” specifies the scope of the reservation. You can give it by name or by number. The scope is ignored for register, register_ignore and clear. If the scope you want isn't available by name, you may specify the number.
    • lun โ€” LUN scope (0x00). This encompasses the entire LUN. ๐Ÿ‘‘
    • extent โ€” Extent scope (0x01).
    • element โ€” Element scope (0x02).
  • -R rtp โ€” specifies the Relative Target Port. This only applies to the Register and Move service action of the Persistent Reserve Out command.
  • -S โ€” enables the SPEC_I_PT bit. This only applies to the Register service action of Persistent Reserve Out. You must also specify at least one Transport ID with -I if this option is set. And plot twist: if you specify a Transport ID, this option is automatically set ๐Ÿ”. It is an error to specify this option for any service action other than Register โ€” so don't try it, she WILL clock you ๐Ÿ’…
  • -T type โ€” specifies the reservation type. You can give it by name or by number. If the type you want isn't available by name, you may specify the number. Supported reservation type names:
    • read_shared โ€” Read Shared mode.
    • wr_ex โ€” Write Exclusive mode. May also be specified as write_exclusive.
    • rd_ex โ€” Read Exclusive mode. May also be specified as read_exclusive.
  • ex_ac โ€” Exclusive access mode. You can also spell it exclusive_access if you're feeling verbose ๐Ÿ’…
    • wr_ex_ro โ€” Write Exclusive Registrants Only mode. Alt spelling: write_exclusive_reg_only.
    • ex_ac_ro โ€” Exclusive Access Registrants Only mode. Alt spelling: exclusive_access_reg_only.
    • wr_ex_ar โ€” Write Exclusive All Registrants mode. Alt spelling: write_exclusive_all_regs.
    • ex_ac_ar โ€” Exclusive Access All Registrants mode. Alt spelling: exclusive_access_all_regs.
  • -U โ€” tells the target to unregister the initiator that sent the Register and Move request. By default the target does not unregister that initiator. Heads up: this option only applies to the Register and Move service action of the Persistent Reserve Out command. That's it, that's the whole vibe ๐ŸŽ€

๐ŸŒธ attrib โ€” the MAM whisperer

okay so this one issues the SCSI READ or WRITE ATTRIBUTE commands, and those bad boys read and write attributes in Medium Auxiliary Memory (MAM) โœจ

and where do you find MAM? mostly in those tiny little flash chips baked into tape cartridges โ€” literally iconic. LTO tapes have MAM, for example. ๐Ÿ’พ

๐Ÿšจ real talk: you must specify either the -r option or the -w option. One of them. Not neither.
  • -r action โ€” specify the READ ATTRIBUTE service action. The options are:
    • attr_values โ€” issue the ATTRIBUTE VALUES service action. Reads and decodes the available attributes and their values. ๐Ÿซถ
    • attr_list โ€” issue the ATTRIBUTE LIST service action. Lists the attributes available to read and write.
    • lv_list โ€” issue the LOGICAL VOLUME LIST service action. Lists the available logical volumes in the MAM.
    • part_list โ€” issue the PARTITION LIST service action. Lists the available partitions in the MAM.
    • supp_attr โ€” issue the SUPPORTED ATTRIBUTES service action. Lists attributes supported for reading or writing โ€” and ngl, these attributes may or may not actually be present in the MAM right now. No promises ๐Ÿ’€
  • -w attr โ€” specify an attribute to write to the MAM. sadly this option is not yet implemented ๐Ÿ˜ญ she's a work in progress.
  • -a num โ€” specify the attribute number to display. Only functions with the attr_values, attr_list and supp_attr arguments to -r. iykyk.
  • -c โ€” display cached attributes. If the device supports this flag, you get to see attributes for the last piece of media loaded in the drive. throwback content fr.
  • -e num โ€” specify the element address. This is how you say which element number in a medium changer to access when reading attributes. The element number could be a picker, a portal, a slot, or a drive. Choose your fighter ๐ŸŒˆ
  • -F form1,form2 โ€” specify the output format for the attribute values (attr_val) display, as a comma separated list of options. The default output is currently set to:
field_all,nonascii_trim,text_raw

Once this code gets ported to FreeBSD 10, any text fields will be converted from their codeset to the user's native codeset with iconv(3). future goals โœจ

โš ๏ธ the text options are mutually exclusive โ€” specify more than one and you'll get unpredictable results, no cap. The nonascii options are also mutually exclusive. Most of the field options can be logically ORed together though, so go off.
  • text_esc โ€” print text fields with non-ASCII characters escaped.
  • text_raw โ€” print text fields natively, no codeset conversion at all.
  • nonascii_esc โ€” if any non-ASCII characters show up in fields that are supposed to be ASCII, escape those non-ASCII characters.
  • nonascii_trim โ€” if any non-ASCII characters show up in fields that are supposed to be ASCII, omit them entirely. bye ๐Ÿ‘‹
  • nonascii_raw โ€” if any non-ASCII characters show up in fields that are supposed to be ASCII, print them exactly as they are.
  • field_all โ€” print all of the prefix fields: description, attribute number, attribute size, and the attribute's readonly status. And if field_all is specified, specifying any other field options will not have an effect. she's the main character, she overrides.
  • field_none โ€” print none of the prefix fields, and only print out the attribute value. But if field_none is specified, specifying any other field options will result in those fields being printed. plot twist ๐ŸŒ€
  • field_desc โ€” print out the attribute description.
  • field_num โ€” print out the attribute number.
  • field_size โ€” print out the attribute size.
  • field_rw โ€” print out the attribute's readonly status.
  • -p part โ€” specify the partition. When the media has multiple partitions, giving different partition numbers lets you peek at the values for each individual partition. ๐Ÿ—‚๏ธ
  • -s start_num โ€” specify the starting attribute number. This requests that the target device return attribute information starting at the given number. like a "start from here" marker.
  • -T elem_type โ€” specify the element type. For medium changer devices this lets you specify the type of the element referenced in the element address (-e). Valid types are: all, picker, slot, portal, and drive. periodt.
  • -V vol_num โ€” specify the number of the logical volume to operate on. If the media has multiple logical volumes, this lets you display or write attributes on the given logical volume. ๐Ÿ’œ

๐Ÿ‘‘ opcodes โ€” the whole menu, please

Issues the REPORT SUPPORTED OPCODES service action of the SCSI MAINTENANCE IN command.

With no arguments, this command returns a list of all SCSI commands supported by the device โ€” including service actions of commands that support service actions. It'll also include the SCSI CDB (Command Data Block) length for each command, plus the description of each command if it's known. full menu with descriptions, we love to see it ๐Ÿ“

  • -o opcode โ€” request info on one specific opcode instead of the whole list of supported commands. If supported, the target returns a CDB-like structure indicating the opcode, the service action (if any), and a mask of bits that are supported in that CDB. targeted. precise. iconic. ๐ŸŽฏ
  • -s service_action โ€” for commands that support a service action, specify which service action to query.
  • -N โ€” okay so picture this: a service action is specified for a given opcode, but the device doesn't support that service action. With -N, the device should not throw a SCSI error โ€” instead it just says in the returned parameter data that the command isn't supported. By default? Yeah, by default if a service action is specified for an opcode and service actions aren't supported for that opcode at all, the device will return an error. So -N is your "chill, don't error out" flag ๐Ÿซถ
  • -T โ€” include timeout values. This one plays nice with the default display (which includes all commands supported by the device), and with the -o and -s options, which request info on a specific command and service action. It asks the device to report Nominal and Recommended timeout values for the given command or commands. Those timeout values are in seconds. The timeout descriptor also includes a command-specific (and yeah, the manpage literally cuts off mid-sentence right there ๐Ÿ˜ญ that's how it is in the source, not me being lazy)

๐ŸŒธ zone ๐ŸŒธ

Manage SCSI and ATA Zoned Block devices, bestie ๐Ÿ’… This lets you manage devices that conform to the SCSI Zoned Block Commands (ZBC) and ATA Zoned ATA Command Set (ZAC) specifications. Devices using these command sets are usually hard drives using Shingled Magnetic Recording (SMR).

There are three types of SMR drives, and yes you need to know all three:

  • Drive Managed โ€” Drive Managed drives look and act just like a standard random access block device, but underneath, the drive reads and writes the bulk of its capacity using SMR zones. Sequential writes will yield better performance, but writing sequentially is not required.
  • Host Aware โ€” Host Aware drives expose the underlying zone layout via SCSI or ATA commands and allow the host to manage the zone conditions. The host is not required to manage the zones on the drive, though. Sequential writes will yield better performance in Sequential Write Preferred zones, but the host can write randomly in those zones.
  • Host Managed โ€” Host Managed drives expose the underlying zone layout via SCSI or ATA commands. The host is required to access the zones according to the rules described by the zone layout. Any commands that violate the rules will be returned with an error ๐Ÿšจ like, actual consequences, no cap.

SMR drives are divided into zones (typically in the range of 256MB each) that fall into three general categories:

  • Conventional โ€” also known as Non Write Pointer zones. These zones can be randomly written without an unexpected performance penalty โœจ
  • Sequential Preferred โ€” these zones should be written sequentially starting at the write pointer for the zone. They may be written randomly. Writes that do not conform to the zone layout may be significantly slower than expected ๐Ÿ˜ฌ
  • Sequential Required โ€” these zones must be written sequentially. If they are not written sequentially, starting at the write pointer, the command will fail ๐Ÿ’€ periodt.
  • -c cmd โ€” specify the zone subcommand:
    • rz โ€” issue the Report Zones command. All zones are returned by default. Specify report options with -o and printing options with -P. Specify the starting LBA with -l. Note that reportzones is also accepted as a command argument ๐Ÿ‘‘
    • open โ€” explicitly open the zone specified by the starting LBA.
    • close โ€” close the zone specified by starting LBA.
    • finish โ€” finish the zone specified by the starting LBA.
    • rwp โ€” reset the write pointer for the zone specified by the starting LBA.
  • -a โ€” for the Open, Close, Finish, and Reset Write Pointer operations, apply the operation to all zones on the drive. All of them. Every single one ๐Ÿซก
  • -l lba โ€” specify the starting LBA. For the Report Zones command, this tells the drive to report starting with the zone that starts at the given LBA. For the other commands, this lets you identify the zone you want by its starting LBA. The LBA may be specified in decimal, hexadecimal or octal notation.
  • -o rep_opt โ€” for the Report Zones command, specify a subset of zones to report:
    • all โ€” report all zones. This is the default.
    • empty โ€” report only empty zones.
    • imp_open โ€” report zones that are implicitly open. This means that the host has sent a write to the zone without explicitly opening the zone.
    • exp_open โ€” report zones that are explicitly open.
    • closed โ€” report zones that have been closed by the host.
    • full โ€” report zones that are full.
    • ro โ€” report zones that are in the read only state. Note that readonly is also accepted as an argument ๐ŸŽ€
    • offline โ€” report zones that are in the offline state.
    • reset โ€” report zones where the device recommends resetting write pointers.
    • nonseq โ€” report zones that have the Non Sequential Resources Active flag set. These are zones that are Sequential Write Preferred, but have been written non-sequentially.
    • nonwp โ€” report Non Write Pointer zones, also known as Conventional zones.
  • -P print_opt โ€” specify a printing option for Report Zones:
    • normal โ€” normal Report Zones output. This is the default. The summary and column headings are printed, fields are separated by spaces and the fields themselves may contain spaces.
    • summary โ€” just print the summary: the number of zones, the maximum LBA (LBA of the last logical block on the drive), and the value of the same field. The same field describes whether the zones on the drive are all identical, all different, or whether they are the same except for the last zone, etc. Little summary slay ๐Ÿ’–
    • script โ€” print the zones in a script friendly format. The summary and column headings are omitted, the fields are separated by commas, and the fields do not contain spaces. The fields contain underscores where spaces would normally be used. Machine-readable queen ๐Ÿ‘‘

๐Ÿ”ฅ epc ๐Ÿ”ฅ

Issue ATA Extended Power Conditions (EPC) feature set commands. Heads up though: this only works on ATA protocol drives, and will not work on SCSI protocol drives. It will work on SATA drives behind a SCSI to ATA translation layer (SAT). It may be helpful to read the ATA Command Set - 4 (ACS-4) description of the Extended Power Conditions feature set, available at t13.org, to understand the details of this particular camcontrol subcommand. Go read the lore, iykyk ๐Ÿ“š

  • -c cmd โ€” specify the epc subcommand:
    • restore โ€” restore drive power condition settings.
      • -r src โ€” specify the source for the restored power settings, either default or saved. This argument is required ๐Ÿšจ
      • -s โ€” save the settings. This only makes sense to specify when restoring from defaults.
    • goto โ€” go to the specified power condition.
  • -p cond โ€” tell it which power condition you want: Idle_a, Idle_b, Idle_c, Standby_y, Standby_z. This one is required, bestie, no skipping it ๐Ÿ’…
  • -D โ€” delayed entry, iconic behavior only. The drive, if it supports this, can slide into the power condition after the command finishes. Patient queen energy โœจ
  • -H โ€” hold the power condition. If the drive supports this, it literally plants its feet: it holds that power condition and rejects every command that would normally make it leave. Not me gatekeeping my own nap ๐Ÿ˜ค

timer

Set the timer value for a power condition and turn the condition on or off. Peep the list display described below to see what the current timer settings actually are for each Idle and Standby mode your drive supports ๐Ÿ‘€

  • -e โ€” enable the power condition. One of -e or -d is required โ€” pick a lane ๐Ÿซถ
  • -d โ€” disable the power condition. One of -d or -e is required, fr fr.
  • -T timer โ€” the timer, in seconds. You can hand it a floating point number with a max supported resolution of tenths of a second. Important caveat: drives may or may not support sub-second timer values, so don't come for me if it rounds ๐ŸŒธ
  • -p cond โ€” the power condition: Idle_a, Idle_b, Idle_c, Standby_y, Standby_z. Required, periodt.
  • -s โ€” save the timer and the enable/disable state. By default, if you don't pass this, only the current values for this power condition get touched. Very "what happens in this session stays in this session" of it ๐Ÿ’€

state

Turn a particular power condition on or off. Simple, clean, main character energy ๐Ÿ‘‘

  • -e โ€” enable the power condition. One of -e or -d is required.
  • -d โ€” disable the power condition. One of -d or -e is required.
  • -p cond โ€” the power condition: Idle_a, Idle_b, Idle_c, Standby_y, Standby_z. Required, as always ๐Ÿ’–
  • -s โ€” save the power condition enable/disable state. By default, if you don't specify this, only the current values for this power condition are affected.

enable

Enable the Extended Power Condition (EPC) feature set. That's it, that's the whole vibe. Go off โœจ


disable

Disable the Extended Power Condition (EPC) feature set. The opposite slay ๐Ÿ™ˆ


source

Specify the EPC power source.

  • -S src โ€” the power source, either battery or nonbattery. Choose wisely ๐ŸŽ€

status

Get the current status of several parameters related to the Extended Power Condition (EPC) feature set โ€” including whether APM and EPC are supported and enabled, whether Low Power Standby is supported, whether setting the EPC power source is supported, whether Low Power Standby is supported, and the current power condition. Yes, Low Power Standby support shows up twice in that list. We keep the facts exactly as they are, no edits, no notes ๐Ÿ’…

  • -P โ€” only report the current power condition. Here's why that matters: some drives will exit their current power condition if they receive any command other than the ATA CHECK POWER MODE command. So if you pass this flag, camcontrol only issues the ATA CHECK POWER MODE command to the drive. Sneaky but considerate ๐Ÿงš

list

Display the ATA Power Conditions log (Log Address 0x08). This shows you the list of Idle and Standby power conditions your drive supports, plus a bunch of parameters about each condition โ€” including whether it's enabled and what the timer value is. Basically the receipts for your drive's whole nap schedule ๐Ÿ”ฅ


timestamp

Issue REPORT TIMESTAMP or SET TIMESTAMP SCSI commands. Either the -r option or the -s option must be specified.

  • -r โ€” report the device's timestamp. If you don't pass any more arguments, the timestamp gets reported using the national representation of the date and time, followed by the time zone. Classic, familiar, cozy ๐ŸŒธ
    • -f format โ€” the strftime format string, as documented in strftime(3), used to format the reported timestamp.
    • -m โ€” report the timestamp as milliseconds since the epoch. Numbers girlies rise โญ
    • -U โ€” report the timestamp using the national representation of the date and time, but override the system time zone and use UTC instead. Time zone said "not today" ๐Ÿ˜ญ
  • -s โ€” set the device's timestamp. Either the -f and -T options or the -U option must be specified.
    • -f format โ€” the strptime format string, as documented in strptime(3). The time must also be specified with the -T option.
    • -T time โ€” provide the time in the format specified with the -f option.
    • -U โ€” set the timestamp to the host system's time in UTC.

devtype

Print out the device type for the specified device. Little identity check, love that for you ๐Ÿฆ‹

  • ata โ€” an ATA device attached directly to an ATA controller
  • satl โ€” a SATA device attached behind a SAS controller via SCSI-ATA Translation Layer (SATL)
  • scsi โ€” a SCSI device
  • nvme โ€” a directly attached NVMe device
  • mmcsd โ€” an MMC or SD device attached via a mmcsd bus
  • none โ€” no device type reported
  • unknown โ€” device type is unknown
  • illegal โ€” a programming error occurred ๐Ÿ’€

depop

The commands necessary to support the depopulation (depop) of defective elements of a device (typically heads for hard drives) or setting a capacity point (typically used on flash drives). It issues either GET PHYSICAL ELEMENT STATUS, REMOVE ELEMENT AND TRUNCATE, or RESTORE ELEMENT AND REBUILD to manage storage elements of a drive.

Okay bestie, deep breath, because this part is serious. Removal or restoration of elements may take up to a day to complete. One of the -d, -l, or -r options must be specified, and these options are mutually exclusive. Only SCSI drives are supported. Changing the storage elements of a storage drive may result in the loss of all data on that storage drive. The drive may need to reinitialize after -d or -r commands. The data on the drive is inaccessible until one of these commands completes. Once one of these commands starts, the drive is format corrupt until the operation successfully completes. While format corrupt, no read or write I/O is possible to the drive. If the drive power cycles, it will remain format corrupt and the operation must be restarted. ๐Ÿ˜ญ This is not a vibe check you want to fail.

TEST UNIT READY or camcontrol tur can monitor an in-progress depop operation. Your little progress bar bestie ๐Ÿซถ

  • -c capacity โ€” specify the desired capacity point for the drive. Valid only for the -d flag.
  • -d โ€” remove the physical element from service, or set the capacity point specified by the -e or -c flags. Heads up: the drive's capacity may be reduced by this operation.
  • -e element โ€” specify the physical element to remove from service. Valid only for the -d flag.
  • -l โ€” report the current status of the physical elements of a drive. The safe, cozy, read-only one ๐Ÿ’œ
  • -r โ€” restore all the eligible physical elements to service.

help

Print out verbose usage information. When in doubt, ask the man page's extroverted cousin โœจ


๐ŸŒˆ ENVIRONMENT ๐ŸŒˆ

The SCSI_MODES variable lets you specify an alternate mode page format file. Customization, we love to see it ๐Ÿ’–

The EDITOR variable determines which text editor camcontrol starts when editing mode pages. Pick your fighter ๐ŸŽ€


๐ŸŽ€ FILES ๐ŸŽ€

  • /usr/share/misc/scsi_modes โ€” the SCSI mode format database.
  • /dev/xpt0 โ€” the transport layer device.
  • /dev/pass* โ€” the CAM application passthrough devices.

โœจ EXAMPLES โœจ

Okay bestie, this is the part where it all clicks โ€” every example is here, and Iโ€™m keeping every flag, number, and warning exactly as it is. No cap. ๐Ÿ’…

Eject the CD from cd1, and print SCSI sense information if the command fails:

camcontrol eject -n cd -u 1 -v

Send the SCSI test unit ready command to da0. The camcontrol utility will report whether the disk is ready, but will not display sense information if the command fails since the -v switch was not specified:

camcontrol tur da0

Send a test unit ready command to da1. Enable kernel error recovery. Specify a retry count of 4, and a timeout of 50 seconds. Enable sense printing (with the -v -flag combo) if the command fails. Since error recovery is turned on, the disk will be spun up if it is not currently spinning. The SCSI task attribute for the command will be set to Head of Queue. The camcontrol utility will report whether the disk is ready:

camcontrol tur da1 -E -C 4 -t 50 -Q head -v

Issue a READ BUFFER command (0x3C) to cd1. Display the buffer size of cd1, and display the first 10 bytes from the cache on cd1. Display SCSI sense information if the command fails:

camcontrol cmd -n cd -u 1 -v -c "3C 00 00 00 00 00 00 00 0e 00" \
        -i 0xe "s1 i3 i1 i1 i1 i1 i1 i1 i1 i1 i1 i1"

Issue a WRITE BUFFER (0x3B) command to cd1. Write out 10 bytes of data, not including the (reserved) 4 byte header. Print out sense information if the command fails. Be very careful with this command, improper use may cause data corruption:

camcontrol cmd -n cd -u 1 -v -c "3B 00 00 00 00 00 00 00 0e 00" \
        -o 14 "00 00 00 00 1 2 3 4 5 6 v v v v" 7 8 9 8

Edit mode page 1 (the Read-Write Error Recover page) for da3, and save the settings on the drive. Mode page 1 contains a disk drive's auto read and write reallocation settings, among other things:

camcontrol modepage da3 -m 1 -e -P 3

Rescan all SCSI buses in the system for devices that have been added, removed or changed:

camcontrol rescan all

Rescan SCSI bus 0 for devices that have been added, removed or changed:

camcontrol rescan 0

Rescan SCSI bus 0, target 1, lun 0 to see if it has been added, removed, or changed:

camcontrol rescan 0:1:0

Set the number of concurrent transactions for da5 to 24:

camcontrol tags da5 -N 24

Disable tagged queueing for da4:

camcontrol negotiate -n da -u 4 -T disable

Negotiate a sync rate of 20MHz and an offset of 15 with da3. Then send a Test Unit Ready command to make the settings take effect:

camcontrol negotiate -n da -u 3 -R 20.000 -O 15 -a

Send the SMP REPORT GENERAL command to ses0, and display the number of PHYs it contains, displaying SMP errors if the command fails:

camcontrol smpcmd ses0 -v -r 4 40 0 00 0 -R 1020 s9 i1

Report security support and settings for ada0:

camcontrol security ada0

Enable security on device ada0 with the password MyPass:

camcontrol security ada0 -U user -s MyPass

Secure erase the security enabled ada0 with user password MyPass.

WARNING! WARNING! WARNING!

The following command will ERASE ALL data from the device, so backup your data before using!

This will restore a solid state drive (SSD) to factory default write performance:

camcontrol security ada0 -U user -e MyPass

Report HPA support and settings for ada0 (also reported via identify):

camcontrol hpa ada0

Enable HPA on ada0 setting the maximum reported sectors to 10240.

WARNING! WARNING! WARNING!

The following command will PREVENT ACCESS to all data on the device beyond this limit until HPA is disabled by setting HPA to native max sectors of the device, which can only be done after a power-on or hardware reset!

DO NOT use this on a device which has an active filesystem:

camcontrol hpa ada0 -s 10240

This will read any persistent reservation keys registered with da0, and display any errors encountered when sending the PERSISTENT RESERVE IN SCSI command:

camcontrol persist da0 -v -i read_keys

Register the persistent reservation key 0x12345678 with da0, apply that registration to all ports on da0, and display any errors that occur when sending the PERSISTENT RESERVE OUT command:

camcontrol persist da0 -v -o register -a -K 0x12345678

Reserve da0 for the exclusive use of the initiator issuing the command. The scope of the reservation is the entire LUN. Any errors sending the PERSISTENT RESERVE OUT command will be displayed:

camcontrol persist da0 -v -o reserve -s lun -k 0x12345678 -T ex_ac

Display the full status of all reservations on da0 and print out status if there are any errors:

camcontrol persist da0 -v -i read_full

This will release a reservation on da0 of the type ex_ac (Exclusive Access). The Reservation Key for this registration is 0x12345678. Any errors that occur will be displayed:

camcontrol persist da0 -v -o release -k 0x12345678 -T ex_ac

Register the key 0x12345678 with da0, specifying that it applies to the SAS initiators with SAS addresses 0x1234567812345678 and 0x8765432187654321:

camcontrol persist da0 -v -o register -K 0x12345678 -S \
        -I sas,0x1234567812345678 -I sas,0x8765432187654321

Move the registration from the current initiator, whose Registration Key is 0x87654321, to the Fibre Channel initiator with the Fiber Channel World Wide Node Name 0x1234567812345678. A new registration key, 0x12345678, will be registered for the initiator with the Fibre Channel World Wide Node Name 0x1234567812345678, and the current initiator will be unregistered from the target. The reservation will be moved to relative target port 2 on the target device. The registration will persist across power losses:

camcontrol persist da0 -v -o register_move -k 0x87654321 \
        -K 0x12345678 -U -p -R 2 -I fcp,0x1234567812345678

Read and decode the attribute values from partition 1 on the tape in tape drive sa0, and will display any SCSI errors that result:

camcontrol attrib sa0 -v -i attr_values -p 1

Request the SMR zone list from disk da0, and print out a summary of the zone parameters, and display any SCSI or ATA errors that result:

camcontrol zone da0 -v -c rz -P summary

Request the list of SMR zones that should have their write pointer reset from the disk da0, and display any SCSI or ATA errors that result:

camcontrol zone da0 -v -c rz -o reset

Issue the Reset Write Pointer command to disk da0 for the zone that starts at LBA 0x2c80000 and display any SCSI or ATA errors that result:

camcontrol zone da0 -v -c rwp -l 0x2c80000

Set the timer for the Idle_a power condition on drive ada0 to 60.1 seconds, enable that particular power condition, and save the timer value and the enabled state of the power condition:

camcontrol epc ada0 -c timer -T 60.1 -p Idle_a -e -s

Tell drive da4 to go to the Standby_z power state (the drive's lowest power state) and hold in that state until it is explicitly released by another goto command:

camcontrol epc da4 -c goto -p Standby_z -H

Report only the power state of drive da2. Some drives will power up in response to the commands sent by the status subcommand, and the -P option causes camcontrol to only send the ATA CHECK POWER MODE command, which should not trigger a change in the drive's power state:

camcontrol epc da2 -c status -P

Display the ATA Power Conditions log (Log Address 0x08) for drive ada0:

camcontrol epc ada0 -c list

Set the timestamp of drive sa0 using a strptime(3) format string followed by a time string that was created using this format string:

camcontrol timestamp sa0 -s -f "%a, %d %b %Y %T %z" \
        -T "Wed, 26 Oct 2016 21:43:57 -0600"

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€


๐Ÿ•ฐ๏ธ HISTORY ๐Ÿ•ฐ๏ธ

The camcontrol utility first appeared in FreeBSD 3.0.

The mode page editing code and arbitrary SCSI command code are based upon code in the old scsi(8) utility and scsi(3) library, written by Julian Elischer and Peter Dufault. The scsi(8) program first appeared in 386BSD 0.1.2.4, and first appeared in FreeBSD in FreeBSD 2.0.5.


๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

Kenneth Merry <ken@FreeBSD.org>


๐Ÿ’€ BUGS ๐Ÿ’€

The code that parses the generic command line arguments does not know that some of the subcommands take multiple arguments. So if, for instance, you tried something like this:

camcontrol cmd -n da -u 1 -c "00 00 00 00 00 v" 0x00 -v

The sense information from the test unit ready command would not get printed out, since the first getopt(3) call in camcontrol bails out when it sees the second argument to -c (0x00), above. Fixing this behavior would take some gross code, or changes to the getopt(3) interface. The best way to circumvent this problem is to always make sure to specify generic camcontrol arguments before any command-specific arguments.


๐Ÿ’– Thatโ€™s the whole CAMCONTROL(8) page, bestie โ€” source/version: Debian, dated December 28, 2023. Now go forth and slay those SCSI commands ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from