OS Manuals

/usr/bin/sg_luns

SCSI utilities for Linux, Unix and Windows

From sg3-utils 1.49-r3 (enterprise-packages), captured 2026-11-08 by running sg_luns --help (exit 0). permalink

Usage: sg_luns    [--decode] [--help] [--hex] [--inhex-FN] [--inner-hex]
                  [--json[=JO]] [--js-file=JFN] [--linux] [--lu_cong]
                  [--maxlen=LEN] [--quiet] [--raw] [--readonly]
                  [--select=SR] [--sinq_inraw=RFN] [--verbose] [--version]
                  DEVICE
     or
       sg_luns    --test=ALUN [--decode] [--hex] [--lu_cong] [--verbose]
  where:
    --decode|-d        decode all luns into component parts
    --help|-h          print out usage message
    --hex|-H           output response in hexadecimal; used twice
                       shows decoded values in hex
    --inhex=FN|-i FN    contents of file FN treated as hex and used
                        instead of DEVICE which is ignored
    --inner-hex|-I     when --decode given, output decoded values in
                       hex (def: decimal)
    --json[=JO]|-j[=JO]    output in JSON instead of plain text
                           Use --json=? for JSON help
    --js-file=JFN|-J JFN    JFN is a filename to which JSON output is
                            written (def: stdout); truncates then writes
    --linux|-l         show Linux integer lun after T10 representation
    --lu_cong|-L       decode as if LU_CONG is set; used twice:
                       decode as if LU_CONG is clear
    --maxlen=LEN|-m LEN    max response length (allocation length in cdb)
                           (def: 0 -> 8192 bytes)
    --quiet|-q         output only ASCII hex lun values
    --raw|-r           output response in binary
    --readonly|-R      open DEVICE read-only (def: read-write)
    --select=SR|-s SR    select report SR (def: 0)
                          0 -> luns apart from 'well known' lus
                          1 -> only 'well known' logical unit numbers
                          2 -> all luns
                          0x10 -> administrative luns
                          0x11 -> admin luns + non-conglomerate luns
                          0x12 -> admin lun + its subsidiary luns
    --sinq_inraw=RFN|-Q RFN    read raw (binary) standard INQUIRY
                               response from the RFN filename
    --test=ALUN|-t ALUN    decode ALUN and ignore most other options
                           and DEVICE (apart from '-H')
    --verbose|-v       increase verbosity
    --version|-V       print version string and exit

Performs a SCSI REPORT LUNS command or decodes the given ALUN. When SR is
0x10 or 0x11 DEVICE must be LUN 0 or REPORT LUNS well known logical unit;
when SR is 0x12 DEVICE must be an administrative logical unit. When the
--test=ALUN option is given, decodes ALUN rather than sending a REPORT
LUNS command.
Options (18)
OptionDescriptionSource
--inhex, -i FN|-iFN is expected to be a file name (or '-' for stdin) which contains ASCII hexadecimal or binary representing a REPORT LUNS response.help + man
--json JO]|-j[=JOoutput in JSON instead of plain text Use --json=? for JSON helphelp
--js-file, -J JFN|-JJFN is a filename to which JSON output is written (def: stdout);help + man
--maxlen, -m LEN|-mmax response length (allocation length in cdb) (def: 0 -> 8192 bytes)help + man
--select, -s SR|-sselect report SR (def: 0) 0 -> luns apart from 'well known' lus 1 -> only 'well known' logical unit numbers 2 -> all luns 0x10 -> administrative luns 0x11 -> admin luns + non-conglomerate luns 0x12…help + man
--sinq_inraw, -Q RFN|-Qwhere RFN is a filename containing binary standard INQUIRY response data that matches either DEVICE or FN.help + man
--test, -t ALUN|-tALUN is assumed to be a hexadecimal number in ASCII hex or the letter 'L' followed by a decimal number (see below).help + man
-d, --decodedecode LUNs into their component parts, as described in the LUN section of SAM-3, SAM-4 and SAM-5. (in the manual page but not in --help)man
-h, --helpoutput the usage message then exit. (in the manual page but not in --help)man
-H, --hex[device mode] when given once this utility will output the SCSI response (i.e. the data-out buffer) to the REPORT LUNS command in ASCII hex then exit. (in the manual page but not in --help)man
-I, --inner-hexused together with the --decode option so that the decoded values are shown in hexadecimal. (in the manual page but not in --help)man
-l, --linuxthis option is only available in Linux. (in the manual page but not in --help)man
-L, --lu_congthis option is only considered with --decode. (in the manual page but not in --help)man
-q, --quietoutput only the ASCII hex rendering of each report LUN, one per line. (in the manual page but not in --help)man
-r, --rawoutput the SCSI response (i.e. the data-out buffer) in binary (to stdout). (in the manual page but not in --help)man
-R, --readonlyopen the DEVICE read-only (e.g. in Unix with the O_RDONLY flag). (in the manual page but not in --help)man
-v, --verboseincrease the level of verbosity, (i.e. debug output). (in the manual page but not in --help)man
-V, --versionprint the version string and then exit. (in the manual page but not in --help)man
Exit status (1) from the manual page
0it is successful

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.