SGDIAG(8)

๐Ÿ“ฆ version 1.6.6, in opensuse-leap 16.0

๐Ÿ’… 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 by sgdiag
  • -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)
  • -i N โ€” Autorun for the device at Index N, 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 is 150 minutes, which should suffice for 150 GB disks. larger disks require more time. figure approximately 1 minute 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.net for a bug list and any later versions of this utility. go check the source, bestie, it's literally right there ๐ŸŒˆ

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