SG_SAT_IDENTIFY(8)
π sg_sat_identify β the ATA IDENTIFY whisperer (sg3_utils manual, bestie edition) π
okay so real talk: this is a page from sg3_utils, and the star of the show is sg_sat_identify. she's giving "middlewoman between you and your ATA disk" and honestly? iconic. let's get into it. β¨
πΈ NAME πΈ
sg_sat_identify β literally just here to send an ATA IDENTIFY DEVICE command via the SCSI to ATA Translation (SAT) layer. that's it. that's her whole job and she ate. π
π¦ SYNOPSIS π¦
sg_sat_identify [--ck_cond] [--extend] [--help] [--hex] [--ident]
[--len=CLEN] [--packet] [--raw] [--readonly] [--verbose] [--version]
DEVICE
π DESCRIPTION π
so bestie, what this utility does is send either an ATA IDENTIFY DEVICE command or an ATA IDENTIFY PACKET DEVICE command to DEVICE, and then it prints out the response. and who responds to these? the ATA disks answer to the first one, and the ATAPI devices answer to the second one. respectively. periodt. π
and here's the lil twist β she does not just yeet these commands straight at the device. nope. they get sent over a SCSI transport, which is assumed to contain a SCSI to ATA Translation (SAT) Layer (SATL). and that SATL can be living in an operating system driver, or in host bus adapter firmware, or in some external enclosure. she's flexible like that. π§
now for the lore, because i know you love the lore: the SAT standard (SAT ANSI INCITS 431-2007, and the prior draft is sat-r09.pdf over at www.t10.org) defines two SCSI "ATA PASS-THROUGH" commands β one using a 16 byte "cdb" and the other with a 12 byte cdb. this utility defaults to using the 16 byte cdb variant. π
and it gets better: SAT-4 revision 5 added a SCSI "ATA PASS-THROUGH(32)" command. also, SAT-2 and SAT-3 are now also standards β SAT-2 ANSI INCITS 465-2010 and SAT-3 ANSI INCITS 517-2015. the SAT-4 project is near standardization and the most recent draft is sat4r06.pdf. so yeah, we're stanning standards here. π
β¨ OPTIONS β¨
quick heads up before the list: arguments to long options are mandatory for short options as well. no skipping, bestie. π«Ά
-c,--ck_condβ sets theCK_CONDbit in the ATA PASS-THROUGH SCSI cdb. default setting is clear (i.e.0). when it's set, the SATL should yield a sense buffer containing an ATA Result descriptor no matter what β success or failure, she doesn't care. when it's clear, the SATL should only yield that sense buffer with the ATA Result descriptor if the command failed. subtle but important, okay? π-e,--extendβ sets theEXTENDbit in the ATA PASS-THROUGH SCSI cdb. default is clear (i.e.0). when it's set, a 48 bit LBA command gets sent to the device. oh and this option has no effect when--len=12. noted. π-h,--helpβ outputs the usage message summarizing the command line options, then dips. and it ignores DEVICE if given β like, she'll just pretend you didn't say it. π-H,--hexβ outputs the ATA IDENTIFY (PACKET) DEVICE response in hex. and the count matters here so pay attention:- default action (i.e. without any
-Hoptions) is to output the response in hex, grouped in 16 bit words (i.e. the ATA standard's preference). - when given once, the response is output in ASCII hex bytes (i.e. the SCSI standard's preference).
- when given twice (i.e.
-HH), the output is in hex, grouped in 16 bit words, same as the default but without a header. - when given thrice (i.e.
-HHH), the output is in hex, grouped in 16 bit words, in a format that is acceptable forhdparm --Istdinto process. π₯ -HHHHsimply outputs hex data bytes, space separated, 16 per line. that's the whole bit. π
- default action (i.e. without any
-i,--identβ outputs the World Wide Name (WWN) of the device. this should be a NAA-5 64 bit number, and it's output in hex prefixed with"0x". if it's not available then"0x0000000000000000"is what you get β she's not gonna make something up. the equivalent for a SCSI disk (i.e. its logical unit name) can be found with"sg_vpd -ii". iykyk. π-l,--len=CLENβCLENis the length of the SCSI cdb used for the ATA PASS-THROUGH command.CLENcan either be12,16or32. the default is16. the larger cdb sizes are needed for 48 bit LBA addressing of ATA devices. and the ATA Auxiliary and ICC registers are only conveyed with the 32 byte cdb variant. no cap. π-p,--packetβ sends an ATA IDENTIFY PACKET DEVICE command (via the SATL). the default action is to send an ATA IDENTIFY DEVICE command. btw heads up: the ATAPI specification by T13 (i.e. the PACKET interface) is now obsolete. π-r,--rawβ outputs the ATA IDENTIFY (PACKET) DEVICE response in binary. you should pipe that output to a file or another utility when this option is used, fr fr β don't just stare at it. the binary goes tostdout, and errors go tostderr. π¦-R,--readonlyβ opens the DEVICE read-only (e.g. in Unix with theO_RDONLYflag). the default is to open it read-write. π-v,--verboseβ increases the level or verbosity. that's it, she's just louder now. π₯-V,--versionβ print out version string. short and sweet. β
π§ NOTES π§
listen, because the response to the IDENTIFY (PACKET) DEVICE command is super important for the correct use of an ATA(PI) device (and is typically the first command sent), a SATL should provide an ATA Information VPD page which contains the similar information. helpful queen behavior. π«Ά
now here's a genuinely cursed little fact: the SCSI ATA PASS-THROUGH (12) command's opcode is 0xa1 and it clashes with the MMC set's BLANK command used by cd/dvd writers. so a SATL in front of an ATAPI device that uses MMC (i.e. has peripheral device type 5) probably should treat opcode 0xa1 as a BLANK command and send it through to the cd/dvd drive. meanwhile the ATA PASS-THROUGH (16) command's opcode (0x85) does not clash with anything, so it is a better choice. pick the safer one, bestie. π
also, history lesson: prior to Linux kernel 2.6.29, USB mass storage limited sense data to 18 bytes, which made the --ck_cond option yield strange (truncated) results. ancient drama. π
π EXAMPLES π
these examples use Linux device names and a Linux utility called hdparm. for suitable device names in other supported Operating Systems, go see the sg3_utils(8) man page. π
okay so in this first one, /dev/sdb is a SATA 2.5" disk connected via a USB (type C connector) dongle that implements the UAS (USB attached SCSI) protocol (also known as UASP). and UAS is a vast improvement over the USB mass storage class. glow-up of the century, honestly. β¨
# sg_sat_identify /dev/sdb
Response for IDENTIFY DEVICE ATA command:
00 0c5a 3fff c837 0010 0000 0000 003f 0000 .Z ?. .7 .. .. .. .?
..
....
the hexadecimal ASCII (with plain ASCII to the right) output is abridged to a single line (i.e. the first 16 bytes (or 8 words)). now let's decode some of that ATA Identify response. first, sg_inq can decode a few strings: π
# sg_sat_identify -HHHH /dev/sdb | sg_inq --ata -I -
ATA device: model, serial number and firmware revision:
ST9500420AS 5VJCE6R7 0002SDM1
for a lot more details, the hdparm utility is a good choice: π
# sg_sat_identify -HHH /dev/sdb | hdparm --Istdin
ATA device, with non-removable media
Model Number: ST9500420AS
Serial Number: 5VJCE6R7
Firmware Revision: 0002SDM1
Transport: Serial
Standards:
....
there are about 80 more lines of details decoded by hdparm in this case. and notice the difference in the number of "H" options: three give an unadorned hex output arranged in (little endian) words (i.e. 16 bits each), while four "H" options give an unadorned hex output in bytes (i.e. 8 bits each). the way that one extra H changes everything. π
π EXIT STATUS π
the exit status of sg_sat_identify is 0 when it is successful. otherwise, see the sg3_utils(8) man page. simple as that, bestie. π«Ά
π AUTHOR π
written by Douglas Gilbert. icon. π
π REPORTING BUGS π
report bugs to <dgilbert at interlog dot com>. she wants to know. π
β COPYRIGHT β
copyright Β© 2006-2020 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. like, none. zero. don't come for her. π
π₯ SEE ALSO π₯
sg_vpd(sg3_utils)sg_inq(sg3_utils)sdparm(sdparm)hdparm(hdparm)
and that's the whole page, bestie! π¦ this was sg_sat_identify, part of sg3_utils version 1.45, dated January 2020. go forth and identify your devices responsibly. mwah. πβ¨π
π¦ 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