# phpman > man > sg_modes(8)

[SG_MODES(8)](https://www.chedong.com/phpMan.php/man/SGMODES/8/markdown)                                   SG3_UTILS                                  [SG_MODES(8)](https://www.chedong.com/phpMan.php/man/SGMODES/8/markdown)



## NAME
       sg_modes - reads mode pages with SCSI MODE SENSE command

## SYNOPSIS
       **sg**___**modes**  [_--all_]  [_--control=PC_] [_--dbd_] [_--dbout_] [_--examine_] [_--flexible_] [_--help_] [_--hex_]
       [_--list_]  [_--llbaa_]  [_--maxlen=LEN_]  [_--page=PG[,SPG]_]  [_--raw_]  [_-R_]  [_--readwrite_]  [_--six_]
       [_--verbose_] [_--version_] [_DEVICE_]

       **sg**___**modes**  [_-6_]  [_-a_]  [_-A_]  [_-c=PC_]  [_-d_]  [_-D_]  [_-e_]  [_-f_]  [_-h_]  [_-H_]  [_-l_]  [_-L_]  [_-m=LEN_]
       [_-p=PG[,SPG]_] [_-r_] [_-subp=SPG_] [_-v_] [_-V_] [_-w_] [_-?_] [_DEVICE_]

## DESCRIPTION
       This utility sends a MODE SENSE SCSI command to the _DEVICE_ and outputs the response. There is
       a 6 byte and 10 byte (cdb) variant of the MODE SENSE command, this utility defaults to the 10
       byte variant. The SPC-4 standard (and SPC-5 drafts) include a note stating that  implementers
       should  migrate away from the SCSI MODE [SELECT(6)](https://www.chedong.com/phpMan.php/man/SELECT/6/markdown) and MODE [SENSE(6)](https://www.chedong.com/phpMan.php/man/SENSE/6/markdown) commands in favour of the
       10 byte variants (e.g. MODE [SENSE(10)](https://www.chedong.com/phpMan.php/man/SENSE/10/markdown)).

       This utility decodes mode page headers and block descriptors but outputs the contents of each
       mode  page in hex. It also has no facility to change the mode page contents or block descrip‐
       tor data. Mode page contents are decoded and can be changed by the **sdparm** utility.

       This utility supports two command line syntaxes, the preferred one is shown first in the syn‐
       opsis  and explained in this section. A later section on the old command line syntax outlines
       the second group of options.

       If no page is given (and _--list_ is not selected) then _--all_ is assumed. The _--all_ option  re‐
       quests all mode pages (but not subpages) in a single response.

## OPTIONS
       Arguments to long options are mandatory for short options as well.

### -a --all
              output all the mode pages reported by the _DEVICE_. This is what the page code 63 (0x3f)
              is defined to do. When used once, mode subpages are not fetched. When used twice (e.g.
              '-aa'),   all   mode   pages  and  subpages  are  requested  which  is  equivalent  to
              '--page=63,255'.

### -c --control
              _PC_ is the page control value. Up to four different versions of each page are  held  by
              the device:
                **0** : current values (i.e. those active at present)
                **1** : changeable values
                **2** : default values (i.e. the manufacturer's settings)
                **3** : saved values
              The  changeable values are bit masks showing which fields could be changed with a MODE
              SELECT. The saved values will be re-instated the next time the device is power  cycled
              or reset. If this option is not given then current values [0] are assumed.

### -d --dbd
              disable  block  descriptors. By default, block descriptors (usually one (for disks) or
              none) are returned in a MODE SENSE response. This option sets the "disable  block  de‐
              scriptors" (DBD) bit in the cdb which instructs the device not to return any block de‐
              scriptors in its response. Older devices may not support this setting and  may  return
              an  "illegal  request"  sense key; alternatively they may ignore it. Oddly the Reduced
              Block Command set (RBC) requires this bit set.

### -D --dbout
              disable outputting block descriptors. Irrespective of whether  block  descriptors  are
              present in the response or not, they are not output.

### -e --examine
              examine  each mode page in the range 0 through to 62 (inclusive).  If some response is
              given then print out the mode page name or number (in hex) if the name is not known.
              The sdparm utility which lists mode and VPD pages also has  a  **--examine**  option  will
              similar functionility.

### -f --flexible
              Some  devices,  bridges and/or drivers attempt crude translations between MODE SENSE 6
              and 10 byte commands without correcting the response. This will cause the response  to
              be mis-interpreted (usually with an error saying the response is malformed). With this
              option, the length of the response is checked, and if it looks wrong, the response  is
              then decoded as if the other mode sense (cdb length) was sent.

### -h --help
              print out the usage message then exit.

### -H --hex
              The  default  action  is  to decode known mode page numbers (and subpage numbers) into
              text. When this option is used once, the response is output in hexadecimal to  stdout.
              When  this  option is used twice, mode page numbers and page control values are output
              in hex.
              When this option is used three times, the full response to the MODE SENSE  command  is
              output  in  hex  to stdout without any decoding. This form can be redirected to a file
              (or piped) and then used 'sdparm --inhex=' to decode.

### -l --list
              lists all common page and subpage codes and their names that are found in the  command
              set  that  matches  the  peripheral  type  of  the  given _DEVICE_.  If no _DEVICE_ and no
              _--page=PG_ is given then the common page and subpage codes and their names  are  listed
              for  SBC (e.g. a disk). If no _DEVICE_ is given and a _--page=PG_ is given then the common
              page and subpage codes and their names are listed for the command set whose peripheral
              device type matches the value given to _PG_. For example 'sg_mode --list --page=1' lists
              the command mode pages and subpages for tape devices. Additionally if a  sub_page_code
              is  given  then it is interpreted as a transport identifier and command transport spe‐
              cific mode page codes and their names are listed following the main  mode  page  list.
              Other options are ignored.

### -L --llbaa
              set  the Long LBA Accepted (LLBAA) bit in the MODE SENSE (10) cdb. This bit is not de‐
              fined in the MODE SENSE (6) cdb so setting the '-L' and '--six' options is reported as
              an  error. When set the _DEVICE_ may respond with 16 byte block descriptors as indicated
              by the 'LongLBA' field in the response. In most  cases  setting  this  option  is  not
              needed.

### -m --maxlen
              The  _LEN_  argument  is  the  maximum  response  length in bytes. It is the 'allocation
              length' field in the cdb. When not given (or _LEN_ is zero) then the  allocation  length
              field  is  set to 4096 for MODE SENSE (10) or 252 for MODE SENSE (6). The _LEN_ argument
              must be non-negative and no greater than 65535 for MODE SENSE  (10)  and  not  greater
              than 255 for MODE SENSE (6).

### -O --old
              Switch to older style options. Please use as first option.

### -p --page
              page code to fetch. The _PG_ is assumed to be a decimal value unless prefixed by '0x' or
              has a trailing 'h'. It should be a value between 0 and 63 (inclusive). When not  given
              and  a default is required then a value of 63 (0x3f), which fetches all mode pages, is
              used.
              Alternatively an acronym for the mode page can be given. The available acronyms can be
              listed  out  with the _--page=xxx_ option. They are almost the same as the acronyms used
              for mode pages in the sdparm utility.

### -p --page
              page code and subpage code values to fetch. Both arguments are assumed to  be  decimal
              unless flagged as hexadecimal. The page code should be between 0 and 63 inclusive. The
              subpage code should be between 0 and 255 inclusive. The default value for the  subpage
              code is 0.

### -r --raw
              output the response in binary to stdout. Error messages and warnings, if any, are sent
              to stderr. When this option is used twice (e.g. '-rr') then has  the  same  action  as
              '-R'

### -R
              decimal digits (e.g. "3e"). Useful as input (after editing) to the [sg_wr_mode(8)](https://www.chedong.com/phpMan.php/man/sgwrmode/8/markdown) util‐
              ity.

### -w --readwrite
              open _DEVICE_ in "read-write" mode. Default is to open it in read-only mode.

### -6 -s --six
              by default this utility sends a 10 byte MODE SENSE command to the _DEVICE_. However some
              SCSI devices only support 6 byte MODE SENSE commands (e.g. SCSI-2 tape  drives).  This
              parameter forces the use of 6 byte MODE SENSE commands.

### -v --verbose
              increase level of verbosity. Can be used multiple times.

### -V --version
              print out version string then exit.

## NOTES
       If  the  normal  sg_modes  utility  fails  with "illegal command operation code" then try the
       '--six' (or '-6') option.

       This utility performs a SCSI INQUIRY command to determine the peripheral type of  the  device
       (e.g.  0 -> Direct Access Device (disk)) prior to sending a MODE SENSE command. This helps in
       decoding the block descriptor and mode pages.

       This utility opens _DEVICE_ in read-only mode (e.g. in Unix, with the  O_RDONLY  flag)  by  de‐
       fault. It will open _DEVICE_ in read-write mode if the _--readwrite_ option is given.

       In  the 2.4 series of Linux kernels the _DEVICE_ must be a SCSI generic (sg) device. In the 2.6
       series block devices (e.g. SCSI disks and DVD drives) can  also  be  specified.  For  example
       "sg_modes -a /dev/sda" will work in the 2.6 series kernels.

## EXIT STATUS
       The  exit  status  of sg_modes is 0 when it is successful. Otherwise see the [sg3_utils(8)](https://www.chedong.com/phpMan.php/man/sg3utils/8/markdown) man
       page.

## OLDER COMMAND LINE OPTIONS
       The options in this section were the only ones available prior to sg3_utils  version  1.23  .
       Since then this utility defaults to the newer command line options which can be overridden by
       using _--old_ (or _-O_) as the first option. See the ENVIRONMENT VARIABLES  section  for  another
       way to force the use of these older command line options.

### -6
              ter forces the use of 6 byte MODE SENSE commands.  See _--six_ in the main description.

### -a

### -A
              in the new syntax.

### -c --control

### -d --dbd

### -D --dbout

### -e --examine

### -f --flexible

### -h
              text. With this option mode page numbers (and subpage numbers) are output in hexadeci‐
              mal.

### -H

### -l --list

### -L --llbaa

### -N --new
              Switch to the newer style options.

### -m --maxlen

### -p
              to 63 decimal). The default value when required is 3f (fetch  all  mode  pages).  Note
              that  an acronym for the page and/or subpage values is not accepted in this older for‐
              mat (because any acronym starting with the letters 'a' to 'f' is ambiguous;  it  could
              either be a hex number or an acronym).

### -p
              page code and subpage code values to fetch. The page code should be a hexadecimal num‐
              ber between 0 and 3f inclusive. The subpage code should be a  hexadecimal  number  be‐
              tween 0 and ff inclusive. The default value for the subpage code is 0.

### -r
              decimal digits (e.g. "3e"). Useful as input (after editing) to the [sg_wr_mode(8)](https://www.chedong.com/phpMan.php/man/sgwrmode/8/markdown) util‐
              ity.

### -subp
              sub  page  code to fetch. Should be a hexadecimal number between 0 and 0xff inclusive.
              The default value is 0.

### -v

### -V

### -w --readwrite

       **-?**     output usage message then exit. Ignore all other parameters.

## ENVIRONMENT VARIABLES
       Since sg3_utils version 1.23 the environment variable SG3_UTILS_OLD_OPTS can be  given.  When
       it  is  present  this  utility will expect the older command line options. So the presence of
       this environment variable is equivalent to using _--old_ (or _-O_) as the first command line  op‐
       tion.

## AUTHOR
       Written by Douglas Gilbert

## REPORTING BUGS
       Report bugs to <dgilbert at interlog dot com>.

## COPYRIGHT
       Copyright © 2000-2020 Douglas Gilbert
       This software is distributed under the GPL version 2. There is NO warranty; not even for MER‐
       CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

## SEE ALSO
       [**sdparm(8)](https://www.chedong.com/phpMan.php/man/sdparm/8/markdown),**   **sg**___**wr**___**[mode(8)](https://www.chedong.com/phpMan.php/man/mode/8/markdown),**   [**sginfo(8)](https://www.chedong.com/phpMan.php/man/sginfo/8/markdown),**   **sgmode(scsirastools),**   [**scsiinfo(net)](https://www.chedong.com/phpMan.php/man/scsiinfo/net/markdown),**   [**scu(net)](https://www.chedong.com/phpMan.php/man/scu/net/markdown),**
### seatools(seagate)

       All these utilities offer some facility to change mode page (or block descriptor) parameters.



sg3_utils-1.45                             September 2020                                [SG_MODES(8)](https://www.chedong.com/phpMan.php/man/SGMODES/8/markdown)
