SG_GET_LBA_STATUS(8)

✨ SG_GET_LBA_STATUS(8) ✨

okay bestie, welcome to sg_get_lba_status from the sg3_utils fam πŸ’– this little icon sends a SCSI GET LBA STATUS(16 or 32) command and reads back the tea. let's get into it 🫢


🌸 NAME 🌸

sg_get_lba_status β€” send SCSI GET LBA STATUS(16 or 32) command πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

sg_get_lba_status [--16] [--32] [--blockhex] [--brief] [--element-id=EI]
[--help] [--hex] [--inhex=FN] [--json[=JO]] [--js-file=JFN] [--lba=LBA]
[--maxlen=LEN] [--raw] [--readonly] [--report-type=RT] [--scan-len=SL]
[--verbose] [--version] DEVICE

✨ DESCRIPTION ✨

So what we're doing here is sending the SCSI GET LBA STATUS(16) or GET LBA STATUS(32) command to DEVICE and then outputting the response. The 16 byte command variant showed up in (draft) SBC-3 revision 20, and honestly any device that supports logical block provisioning should support this command. The GET LBA STATUS(32) command? That one got added later, in (draft) SBC-4 revision 14. slay for progress 🌈

The default action is genuinely satisfying: it decodes the response into one LBA status descriptor per line, then outputs a header plus the status descriptors to stdout. The descriptor LBA comes out in hex (prefixed by 0x) and the number of blocks comes out in decimal, followed by the provisioning status, LBA accessibility and additional status in decimal. The provisioning status can be in the range 0 to 15, of which only 0 (mapped or unknown), 1 (unmapped), 2 (anchored), 3 (mapped) and 4 (unknown) are used currently. If that's too much output for you, the --brief option reduces it. obsessed πŸ’œ

And here's a cute alternative: rather than sending this SCSI command to DEVICE, if the --inhex=FN option is given, then the contents of the file named FN are decoded as ASCII hex and then processed if it was the response of this command. reading from a file instead of a device? main character energy, no cap πŸŽ€


πŸ’… OPTIONS πŸ’…

Quick housekeeping: arguments to long options are mandatory for short options as well. iykyk

  • -S, --16 β€” send the SCSI GET LBA STATUS(16) command, which is the 16 byte variant. In the absence of the --16 or the --32 options, the SCSI GET LBA STATUS(16) command is sent. And if both --16 and the --32 options are given, then the GET LBA STATUS(16) command is sent too.
  • -T, --32 β€” send the SCSI GET LBA STATUS(32) command, which is the 32 byte variant. When given together with the --16 option then this option is ignored (so the GET LBA STATUS(16) command is sent). it's giving "16 wins" πŸ’€
  • -b, --brief β€” when used once, then one LBA status descriptor per line is output to stdout. Each line has this format: "0x<descriptor_LBA> 0x<blocks> <provisioning_status> <additional_status>". So the descriptor's starting LBA and number of blocks are output in hex while the provisioning status and additional status are in decimal. When used twice (e.g. '-bb' or '--brief --brief') then the provisioning status of the given LBA (or LBA 0 if the --lba option is not given) is output to stdout. A check is made that the given LBA lies in the range of the first returned LBA status descriptor (as it should according to SBC-3 revision 20) and warnings are sent to stderr if it doesn't. 🫢
  • -B, --blockhex β€” the number of blocks in each LBA status descriptor is usually displayed in decimal. An exception is when the --brief option is given, in which case it is shown in hexadecimal. When the option is given once, both cases are output in hexadecimal. When the option is given twice, both cases are output in decimal. literally flipping the vibe check on blocks 🌸
  • -e, --element-id=EI β€” where EI is the element identifier of the physical element for which the LBAs shall be reported based on the value in the report type field (i.e. RT). This option is only active with the SCSI GET LBA STATUS(32) command (i.e. it is ignored if the GET LBA STATUS(16) command is sent, which is equivalent to it being set to zero). Valid element identifiers start at 1 and increase in integer order. EI's default value of 0 means that all element identifiers are examined based on the value of the report type field.
  • -h, --help β€” output the usage message then exit. classic πŸŽ€
  • -H, --hex β€” output response to this command in ASCII hex. To produce hex output suitable for a later invocation to fetch with the --inhex=FN option, use this option three times. The short form option makes this more convenient: '-HHH'. ✨
  • -i, --inhex=FN β€” where FN is a filename whose contents are assumed to be ASCII hexadecimal bytes. See the "HEX, BINARY AND JSON FORMATS" section in the sg3_utils manpage for more information. If DEVICE is also given then it is ignored. If the --raw option is also given then the contents of FN are treated as binary.
  • -j[=JO], --json[=JO] β€” output is in JSON format instead of plain text form. Note that arguments to the short and long form are themselves optional and if present start with "=" and no whitespace is permitted around that "=". See sg3_utils_json manpage or use '?' for JO to get a summary. json girlies rise πŸ‘‘
  • -J, --js-file=JFN β€” output is in JSON format and it is sent to a file named JFN. If that file exists then it is truncated. By default, the JSON output is sent to stdout. When this option is given, the --json[=JO] option is implied and need not be given. The --json[=JO] option may still be needed to set the JO parameter to non-default values.
  • -l, --lba=LBA β€” where LBA is the starting Logical Block Address (LBA) to check the provisioning status for. Note that the DEVICE chooses how many following blocks that it will return provisioning status for, limited by --maxlen=LEN.
  • -m, --maxlen=LEN β€” where LEN is the (maximum) response length in bytes. It is placed in the cdb's "allocation length" field. If not given then 24 is used. 24 is enough space for the response header and one LBA status descriptor. LEN should be 8 plus a multiple of 16 (e.g. 24, 40, and 56 are suitable). math girlie behavior fr fr 🧚
  • -r, --raw β€” output response in binary (to stdout) unless the --inhex=FN option is also given. In that case the input file name (FN) is decoded as binary (and the output is not in binary). careful bestie, that flip is real πŸ™ˆ
  • -R, --readonly β€” open the DEVICE read-only (e.g. in Unix with the O_RDONLY flag). The default is to open it read-write.
  • -t, --report-type=RT β€” where RT is 0 for report all LBAs; 1 for report LBAs using non-zero provisioning status; 2 for report LBAs that are mapped; 3 for report LBAs that are de-allocated; 4 for report LBAs that are anchored; 16 for report LBAs that may return an unrecovered error. The REPORT TYPE field was added to the GET LBA STATUS cdb in sbc4r12. Since the REPORT TYPE field is newer than the command, the response contains the RTP bit to indicate whether or not the DEVICE acts on the REPORT TYPE field (set when it does act on it, clear otherwise). 🌟
  • -s, --scan-len=SL β€” where SL is the scan length, which is the maximum number of contiguous logical blocks to be scanned for logical blocks that meet the given report type (i.e. RT). This option is only active with the SCSI GET LBA STATUS(32) command (i.e. it is ignored if the GET LBA STATUS(16) command is sent). The default value of SL is 0 which should be interpreted by the DEVICE as there is no limits to the number of LBAs that shall be scanned.
  • -v, --verbose β€” increase the level of verbosity, (i.e. debug output). Additional output caused by this option is sent to stderr.
  • -V, --version β€” print the version string and then exit.

🐚 NOTES 🐚

A LBA extent is a set of contiguous logical blocks whose address is that of the lowest LB.

In SBC-3 revision 25 the calculation associated with the Parameter Data Length field in the response was modified. Prior to that the byte offset was 8 and in revision 25 it was changed to 4. glow-up for the offset πŸ’…

For a discussion of logical block provisioning see section 4.7 of sbc4r14.pdf at https://www.t10.org (or the corresponding section of a later draft). πŸ¦‹


🌈 EXAMPLES 🌈

This example uses a "canned" hex file rather than a real DEVICE.

# cd <folder at root of sg3_utils source package>
# sg_get_lba_status --inhex=inhex/get_lba_status.hex

Command completed due to meeting capacity of medium
RTP=0x0
[1] LBA: 0x0             blocks:  287453952  mapped (or unknown);  LBA
accessibility not reported
[2] LBA: 0x11223300      blocks:         68  deallocated;  LBA access
not reported  [may contain unrecovered errors]
[3] LBA: 0x11223344      blocks:         51  deallocated;  LBA extent
inaccessible  [may contain unrecovered errors]

⭐ EXIT STATUS ⭐

The exit status of sg_get_lba_status is 0 when it is successful. Otherwise see the sg3_utils(8) man page.


πŸŽ€ AUTHORS πŸŽ€

Written by Douglas Gilbert. legend behavior πŸ‘‘


πŸ“ REPORTING BUGS πŸ“

Report bugs to <dgilbert at interlog dot com>.


Copyright Β© 2009-2026 Douglas Gilbert

This software is distributed under a BSD-2-Clause license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


🌸 SEE ALSO 🌸

sg_write_same,sg_unmap,sg3_utils,sg3_utils_json(sg3_utils)


and that's the whole page bestie β€” this vibe was brought to you by sg3_utils-1.49, dated 2026-06-01, and the manual page header SG_GET_LBA_STATUS(8) which we folded in up top like the icon it is πŸ’œβœ¨

πŸ“¦ where this page comes from