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--16or the--32options, the SCSI GET LBA STATUS(16) command is sent. And if both--16and the--32options 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--16option 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--lbaoption 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--briefoption 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=FNoption, 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 thesg3_utilsmanpage for more information. IfDEVICEis also given then it is ignored. If the--rawoption 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"=". Seesg3_utils_jsonmanpage 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 theDEVICEchooses 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 then24is used.24is enough space for the response header and one LBA status descriptor. LEN should be8plus a multiple of16(e.g.24,40, and56are suitable). math girlie behavior fr fr π§-r,--rawβ output response in binary (to stdout) unless the--inhex=FNoption 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 theDEVICEread-only (e.g. in Unix with theO_RDONLYflag). The default is to open it read-write.-t,--report-type=RTβ where RT is0for report all LBAs;1for report LBAs using non-zero provisioning status;2for report LBAs that are mapped;3for report LBAs that are de-allocated;4for report LBAs that are anchored;16for 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 theDEVICEacts 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 is0which should be interpreted by theDEVICEas 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 π
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
- arch rolling: sg3_utils 1.49-1 Β· GPL-2.0-or-later AND BSD-2-Clause
- nixpkgs unstable: sg3_utils 1.49
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms