SGDIAG(8)
๐ SGDIAG(8) โ the girl's guide
okay so bestie, this is the sgdiag page from the System Manager's Manual, and honestly? it's a whole toolkit. it does Diagnostic functions on SCSI devices โ yes, those devices, and yes, it's as chaotic as it sounds. buckle up ๐
โจ NAME โจ
sgdiag โ Do Diagnostic functions on SCSI devices ๐
๐ฆ SYNOPSIS ๐ฆ
sgdiag [-aefintxI]
๐ธ DESCRIPTION ๐ธ
okay so, sgdiag is a program that uses the SCSI Generic interface to send specific SCSI commands to specified SCSI devices โ it's giving "i speak fluent hardware" energy, honestly. ๐ฅ
no cap, there's a prerequisite: the SCSI Generic interface requires that the kernel .config file have CONFIG_CHR_DEV_SG set. that's the vibe check you must pass, bestie. ๐
a log file named sgdiag.log gets created in the /var/log directory, and it logs the status of the functions plus any errors. so when things go feral, you'll have receipts. ๐
several different functions can be performed with this utility. and when i say several, i mean โ look at this lineup ๐
๐ง c = Compose Command to send
this function allows the user to compose a custom SCSI command to send to one or more devices. it prompts you for:
- the command length
- each command byte
- the write data length
- each write data byte
- the receive data length
it's literally build-a-bear but for SCSI commands, i'm obsessed ๐
๐ฅ r = Reset SCSI bus
this function will send a bus reset signal to the SCSI bus of the selected device. this may be useful to free up a hung device โ it's giving "unplug it and plug it back in" but make it professional โจ
๐ฆ i = Special Ser# Inquiries
this issues several special SCSI inquiry to obtain the serial number of the device. normally this is not needed, since the serial number of most modern devices is included in the standard inquiry โ so it's like, the backup plan's backup plan ๐ซถ
๐ f = Format SCSI disk
this function issues a low-level SCSI format command to the selected device. this will remap any media defects as it formats the disk. and of course, it will erase any data on the selected disk โ ๐จ bestie. that's a real warning. say goodbye to the data.
๐ w = Wipe SCSI disk
this function issues a low-level SCSI format command to the selected device. it will NOT include the previous grown defect list. this may be useful in testing to cause a disk to expose some media defects.
this is dangerous and should not be used on production systems. periodt. ๐
๐ d = Send Diagnostic self-test
this function issues a SCSI Send Diagnostic self-test command to the selected device. the device returns a sense error if the self-test does not succeed. it's the device's little wellness check ๐ธ
๐ s = Start Unit
this function issues a SCSI Start Unit command. some disk drives may not be configured to automatically start after power up. a reported sense of 02-04-02 indicates that this command is needed โ iykyk ๐
โญ t = Stop Unit
this function issues a SCSI Stop Unit command. this might be used in testing to simulate a device failure. it's giving controlled chaos, and honestly? iconic ๐
๐ 1 = Do bug 1 (sense_len = 18)
the standard sg structure only defines 16 bytes of sense data, whereas 18 bytes are needed to parse some illegal request sense keys. this function attempts to request 18 bytes of sense data from the standard sg structure, which should cause a 5/24/00 sense error, but should not cause the driver or the utility to hang or stop working.
lowkey a stress test and i respect it ๐ญ
๐บ 2 = Do bug 2 (INQ hang)
in versions of the old adaptec driver that were delivered with RedHat 6.2, this function will hang the driver by requesting a receive buffer less than 96 bytes. newer versions of the driver should handle this function without error (status = 0). ok so vintage bug, vintage drama ๐
๐ซถ 3 = Do bug 3 (format w short timeout)
a SCSI format command can take several minutes to complete. if the SCSI timeout is set too short, it should cause several retries, followed by marking the SCSI device offline. the device should return to normal after a reboot. so like, it's fine, it's fine, just reboot ๐
๐ OPTIONS ๐
command line options are described below. here's your menu, bestie ๐
-?โ this option displays a summary of the commands accepted bysgdiag-aโ Automatically send command for all devices. if this option is specified, a diagnostic self-test command (function'd') will be sent to each device. all of them. every single one. ๐-eโ Causes any file writes to be avoided, such as the log file.-fโ Causes a Format to be performed on the disk specified by-i. ๐ (reminder: formatting nukes the data, bestie)-iNโ Autorun for the device at IndexN, as shown in the'Num'column. this sends the diagnostic self-test command.-nโ Naming. by default, the device names are displayed as numeric sequences (/dev/sg0). this option shows the device names as alphabetic sequences (/dev/sga). a little rebrand, we love to see it โจ-tโ Timeout for the format operation, in minutes. the default is150minutes, which should suffice for150GB disks. larger disks require more time. figure approximately1minute per GB of disk capacity โ so do the math, don't be out here guessing ๐งฎ-xโ Causes extra debug messages to be displayed. she's chatty, we stan ๐-Iโ Starts the utility in Interactive mode, requiring user input. no autopilot, you're driving ๐
๐ฆ SEE ALSO ๐ฆ
sgdefects(8) โ sgdskfl(8) โ sgmode(8) ๐
๐จ WARNINGS ๐จ
- on some systems with older scsi drivers, the primary defect list cannot be returned without errors. not us, not our fault, but like โ noted ๐
- see
http://scsirastools.sourceforge.netfor a bug list and any later versions of this utility. go check the source, bestie, it's literally right there ๐
๐ COPYRIGHT ๐
Copyright (C) 2001-2002 Intel Corp.
sgdiag is open source software. you can redistribute it and/or modify it under the terms of the BSD License. see the COPYING file included with this software package for more details regarding distribution.
sgdiag is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY โ no promises, no guarantees, no cap ๐ญ
๐ธ AUTHOR ๐ธ
Andy Cress <arcress@users.sourceforge.net> โ thank you for your service, king ๐ซถ
and that's the whole page! ๐ this cutie right here is Version 1.5: 22 Jul 2004 โ vintage but still serving, mwah ๐โจ
๐ฆ where this page comes from
- opensuse-leap 16.0: scsirastools 1.6.6-bp160.1.12 ยท BSD-3-Clause
- opensuse-leap 16.0: scsirastools 1.6.6-bp160.1.12 ยท BSD-3-Clause
- opensuse-leap 16.0: scsirastools 1.6.6-bp160.1.12 ยท BSD-3-Clause
- opensuse-leap 16.0: scsirastools 1.6.6-bp160.1.12 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms