CAMCONTROL(8)
๐ 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 ofcamcontrol devlist. The lun defaults to0.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:
-Ccount โ 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.-ndev_name โ Specify the device type to operate on, e.g."da","cd".-Qtask_attr โ SCSI task attribute for the command, if it is a SCSI command. This may beordered,simple,head, oraca. In most cases this is not needed. The default issimple, which works with all SCSI devices. The task attribute may also be specified numerically.-ttimeout โ SCSI command timeout in seconds. This overrides the default timeout for any given command.-uunit_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-vargument, SCSI bus number, adapter name and unit numbers are printed as well. On the other hand, with the-bargument, 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. Thecamcontrolutility 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,camcontrolwill 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,camcontrolwill 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,camcontrolwill 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.-rreporttype โ Specify the type of report to request from the target:defaultโ Return the default report. This is thecamcontroldefault. 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,camcontrolwill 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-Nor-s.-hโ Print out the device size in human readable (base 2, 1K == 1024) format. This implies-Nand cannot be used with-qor-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 theSCSI READ CAPACITY (10)command. Sends only theSCSI 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-bor-sare 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. Theformatargument 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. Thecamcontrolutility 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,camcontrolwill 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 theSCSI 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 byteMODEcommands instead of default 10 byte. Old devices may not support 10 byteMODEcommands, while new devices may not be able to report all mode pages with 6 byte commands. If not specified,camcontrolstarts 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 than2^^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 hisEDITORenvironment variable, or supply mode page values via standard input, using the same format thatcamcontroluses to display mode page values. The editor will be invoked ifcamcontroldetects 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-lis 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 values1โ Changeable values2โ Default values3โ 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 theCDBspecified causes data to be transferred to or from theSCSIdevice in question, you MUST specify either-ior-o. like, MUST MUST. no skipping.
-a cmd [args]โ this specifies the content of 12ATA Command Blockregisters(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 theSCSI CDB.SCSI CDBsmay 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 iffmtis-, thenlenbytes 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. iffmtis-,lenbytes 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 iffmtis-, 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. iffmtis-,lenbytes 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. iffmtis-,lenbytes 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 makescamcontrolskip 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 than0.-o operationโ specify a PHY control operation. only one-o operationmay 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-dargument to specify the device name.
-d nameโ specify the attached device name. needed when you're using the-o setdevnamephy 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 Gbps0x9โ 3 Gbps0xaโ 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-margument 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โ enablesCAM_DEBUG_INFOprintfs.-Pโ enablesCAM_DEBUG_PERIPHprintfs.-Tโ enablesCAM_DEBUG_TRACEprintfs.-Sโ enablesCAM_DEBUG_SUBTRACEprintfs.-Xโ enablesCAM_DEBUG_XPTprintfs.-cโ enablesCAM_DEBUG_CDBprintfs. This will cause the kernel to print out the SCSI CDBs sent to the specified device(s).-pโ enablesCAM_DEBUG_PROBEprintfs.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. โจ
-Ntags โ 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-vswitch โ its meaning for thiscamcontrolsubcommand 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 thetagsargument. It causescamcontrolto print out the tagged queueing related fields of theXPT_GDEV_TYPECCB: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. Thedev_openingsvalue above cannot go below this number. The default value formintagsis 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. Thedev_openingsvalue cannot go above this number. The default value formaxtagsis 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 aTest Unit Readycommand to the device.-cโ show or set current negotiation settings. This is the default.-Denable|disable โ enable or disable disconnection.-Mmode โ set ATA mode.-Ooffset โ 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.-Rsyncrate โ change the synchronization rate for a device. The sync rate is a floating point value specified in MHz. So, for instance,20.000is a legal value, as is20.-Tenable|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 thenegotiatesubcommand. It causescamcontrolto print out the contents of a Path Inquiry (XPT_PATH_INQ) CCB sent to the controller driver.-Wbus_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-yargument, 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,camcontrolfires off theFORMAT UNITcommand 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. Thencamcontrolpings the device for SCSI sense info every second to figure out how far along the format is. But if you pass-w,camcontrolissues 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 defaultcamcontrolwill 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. ๐ซถ
-aoperation โ 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-Pargument. The number of times is given by the-cargument. ๐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-Uargument. ๐ช
-cpasses โ the number of passes when performing an โoverwriteโ operation. Valid values are between1and31. The default is1. โญ-Iโ when performing an โoverwriteโ operation, the pattern is inverted between consecutive passes. ๐-Ppattern โ 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-yargument, 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,camcontrolissues theSANITIZEcommand with the immediate bit set. This tells the device to immediately return the sanitize command, before the sanitize has actually completed. Then,camcontrolgathers SCSI sense information from the device every second to determine how far along in the sanitize process it is. If the-wargument is specified,camcontrolwill 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,camcontrolwill 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 power127โ maximum performance with standby128โ minimum power without standby254โ maximum performance
If not specified โ APM is disabled. ๐
๐ aam ๐
If optional parameter (-l) specified, enables and sets automatic acoustic management level, where:
1โ minimum noise254โ 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:
-dpwd โ disable device security using the given password for the selected user according to the devices configured security level.-epwd โ 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. ๐ง
-hpwd โ 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. ๐งน
-kpwd โ unlock the device using the given password for the selected user according to the devices configured security level. ๐-lhigh|maximumโ specifies which security level to set when issuing a-spwd command. The security level determines device behavior when the master password is used to unlock the device. When the security level is set tohighthe device requires the unlock command and the master password to unlock. When the security level is set tomaximumthe 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-yargument, below. ๐คซ-spwd โ password the device (enable security) using the given password for the selected user. This option can be combined with other options such as-epwd. ๐
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. ๐ฝ
-Ttimeout โ overrides the default timeout, specified in seconds, used for both-eand-hthis 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.
-Uuser|master โ takes eitheruserormaster. ๐ธ-uuser โ tells it which user to set/use for the action command you're running. Valid values are literally justuserormaster, and if you don't set it, it defaults tomaster. You have to pair this with one of the security action commands, okay? Not optional-optional. Defaults tomaster.-yโ confirm yes to the dangerous stuff (think-eand 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.-ppwd โ 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-yargument below.-smax_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.
-Upwd โ 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-ewithout 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. ๐คซ-smax_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
MG10SFA22TESAS drives.
โ ๏ธ WARNING! WARNING! WARNING! โ ๏ธ Little testing has been done to make sure that different device models from each vendor work correctly with thefwdownloadcommand. 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 thefwdownloadcommand. 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? ๐
-ffw_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-yoption 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. ๐)
-imode โ specify the service action for thePERSISTENT RESERVE INcommand. 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.
-omode โ specify the service action for thePERSISTENT RESERVE OUTcommand. For service actions likeregisterthat 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 asregister, 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 theregisterandregister_ignoreactions. โญ-Itid โ 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-Iarguments. With the Register service action, specifying one or more Transport IDs implicitly enables the-Soption, which turns on theSPEC_I_PTbit. Transport IDs generally have the formatprotocol,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
-kkey โ 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 between0and2^64 - 1, inclusive. ๐-Kkey โ 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 between0and2^64 - 1, inclusive.-pโ enables the Activate Persist Through Power Loss bit. Only used for theregisterandregister_ignoreactions. This requests that the reservation persist across power loss events. your reservation survives the blackout, iconic behavior ๐โจ-sscope โ specifies the scope of the reservation. You can give it by name or by number. The scope is ignored forregister,register_ignoreandclear. 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).
-Rrtp โ specifies the Relative Target Port. This only applies to the Register and Move service action of the Persistent Reserve Out command.-Sโ enables theSPEC_I_PTbit. This only applies to the Register service action of Persistent Reserve Out. You must also specify at least one Transport ID with-Iif 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 ๐-Ttype โ 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 aswrite_exclusive.rd_exโ Read Exclusive mode. May also be specified asread_exclusive.
ex_acโ Exclusive access mode. You can also spell itexclusive_accessif 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-roption or the-woption. One of them. Not neither.
-raction โ 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 ๐
-wattr โ specify an attribute to write to the MAM. sadly this option is not yet implemented ๐ญ she's a work in progress.-anum โ specify the attribute number to display. Only functions with theattr_values,attr_listandsupp_attrarguments 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.-enum โ 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 ๐-Fform1,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 iffield_allis 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 iffield_noneis 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.
-ppart โ specify the partition. When the media has multiple partitions, giving different partition numbers lets you peek at the values for each individual partition. ๐๏ธ-sstart_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.-Telem_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, anddrive. periodt.-Vvol_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 ๐
-oopcode โ 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. ๐ฏ-sservice_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-Nis 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-oand-soptions, 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.
-ccmd โ specify the zone subcommand:rzโ issue the Report Zones command. All zones are returned by default. Specify report options with-oand printing options with-P. Specify the starting LBA with-l. Note thatreportzonesis 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 ๐ซก-llba โ 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.-orep_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 thatreadonlyis 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.
-Pprint_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 thesamefield. Thesamefield 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 ๐
-ccmd โ specify theepcsubcommand:restoreโ restore drive power condition settings.-rsrc โ specify the source for the restored power settings, eitherdefaultorsaved. 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-eor-dis required โ pick a lane ๐ซถ-dโ disable the power condition. One of-dor-eis 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-eor-dis required.-dโ disable the power condition. One of-dor-eis 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, eitherbatteryornonbattery. 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,camcontrolonly 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โ thestrftimeformat string, as documented instrftime(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-fand-Toptions or the-Uoption must be specified.-f formatโ thestrptimeformat string, as documented instrptime(3). The time must also be specified with the-Toption.-T timeโ provide the time in the format specified with the-foption.-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 controllersatlโ a SATA device attached behind a SAS controller via SCSI-ATA Translation Layer (SATL)scsiโ a SCSI devicenvmeโ a directly attached NVMe devicemmcsdโ an MMC or SD device attached via ammcsdbusnoneโ no device type reportedunknownโ device type is unknownillegalโ 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-roptions 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-dor-rcommands. 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-dflag.-dโ remove the physical element from service, or set the capacity point specified by the-eor-cflags. 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-dflag.-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
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 1998, 1999, 2000, 2002, 2005, 2006, 2007 Kenneth D. Merry
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms