Projects / sg3_utils

sg3_utils

sg3_utils is a package of utilities for accessing devices that use SCSI command sets. Most utilities issue a single command and display the response, while some work at a slightly higher level. There are utilities for fetching INQUIRY data and VPD, mode, and log pages. There is support for modern SCSI transports such as SAS and FCP. The package is written for Linux and has been ported to FreeBSD, Solaris, Tru64, and Windows. There is an earlier version of this package for Linux 2.2 series kernels called sg_utils.

Licenses

Recent releases

  •  13 Jun 2014 15:04

    Release Notes: This release adds some ZBC support in the form of sg_rep_zones and sg_reset_wp. Many other cleanups, with some small extensions. It tracks changes made by www.t10.org since April 2014.

    •  03 Apr 2014 04:59

      Release Notes: This release contains mainly bugfixes and code cleanups, with some small extensions. It tracks changes made by www.t10.org since October 2013. sg_xcopy now sends the xcopy(lid1) command to the destination device by default.

      •  16 Oct 2013 03:32

        Release Notes: This release contains mainly bugfixes and code cleanups, with some small extensions. It tracks changes made by www.t10.org since May 2013.

        •  03 Jun 2013 03:39

          Release Notes: This release adds several features to the sg_xcopy utility and improves 64 bit LUN handling. www.t10.org changes since January 2013 have been tracked .

          •  18 Jan 2013 15:25

            Release Notes: This release adds the sg_compare_and_write utility. www.t10.org changes since October 2012 have been tracked .

            Recent comments

            05 Apr 2014 17:59 dpgilbert

            The proposed read-only flag added to sg_sat_set_features and will appear in version 1.39. Best to email patches like that directly to me as I don't check this site that often.

            More information about sg_xcopy: its xcopy(lid1) functionality has been ported to ddpt (https://freecode.com/projects/ddpt). Further, ODX support (aka: xcopy v2, lite) is being added to ddpt and will appear shortly.

            10 Dec 2013 00:05 lucasrangit

            Using sg_sat_set_features to send EPC (TAPM) power commands requires ability to open device as read-only otherwise, drivers will wake up device and issue IDENTIFY and READ commands potentially negating power condition specified in command.

            Below is a patch based off similar work in sg_start to illustrate. It works for me as I have confirmed the power condition using `hdparm -C /dev/sda` after issuing `sg_sat_set_features --feature=74 --count=0 --lba=1 /dev/sda` to transition to Standby_z (spin-down).

            If this is acceptable, I would like to complete the patch to the necessary documentation and perform additional testing.

            --- a/src/sg_sat_set_features.c
            +++ b/src/sg_sat_set_features.c
            @@ -55,6 +55,7 @@
            {"help", no_argument, 0, 'h'},
            {"len", required_argument, 0, 'l'},
            {"lba", required_argument, 0, 'L'},
            + {"readonly", no_argument, 0, 'r'},
            {"verbose", no_argument, 0, 'v'},
            {"version", no_argument, 0, 'V'},
            {0, 0, 0, 0},
            @@ -79,6 +80,9 @@
            " --lba=LBA | -L LBA LBA field contents (def: 0)\n"
            " --len=16|12 | -l 16|12 cdb length: 16 or 12 bytes "
            "(def: 16)\n"
            + " --readonly | -r open DEVICE read-only "
            + "(def: read-write)\n"
            + " recommended if DEVICE is ATA disk\n"
            " --verbose | -v increase verbosity\n"
            " --version | -V print version string and exit\n\n"
            "Sends an ATA SET FEATURES command via a SAT pass through.\n"
            @@ -256,12 +260,13 @@
            int lba = 0;
            int verbose = 0;
            int ck_cond = 0;
            + int rdonly = 0;
            int cdb_len = SAT_ATA_PASS_THROUGH16_LEN;

            while (1) {
            int option_index = 0;

            - c = getopt_long(argc, argv, "c:Cf:hl:L:vV", long_options,
            + c = getopt_long(argc, argv, "c:Cf:hl:L:rvV", long_options,
            &option_index);
            if (c == -1)
            break;
            @@ -302,6 +307,8 @@
            return SG_LIB_SYNTAX_ERROR;
            }
            break;
            + case 'r':
            + rdonly = 1;
            case 'v':
            ++verbose;
            break;
            @@ -334,7 +341,7 @@
            return 1;
            }

            - if ((sg_fd = sg_cmds_open_device(device_name, 0 /* rw */,
            + if ((sg_fd = sg_cmds_open_device(device_name, rdonly,
            verbose)) < 0) {
            fprintf(stderr, "error opening file: %s: %s\n",
            device_name, safe_strerror(-sg_fd));

            03 Jun 2013 21:52 dpgilbert

            'Does sdparm support SCSI FW download?' No but sg_write_buffer in this package does.

            03 Jun 2013 21:49 dpgilbert

            With regard to the sg_xcopy offer by yuvalkashtan, a sg_xcopy (and sg_copy_results) was added in version 1.34 . There have been several extensions and fixes added in versions 1.35 and 1.36 . Are there more features that you could suggest for sg_xcopy?

            25 Apr 2013 16:01 Tom4015

            Does Sdparm support SCSI FW download?

            Screenshot

            Project Spotlight

            OpenStack4j

            A Fluent OpenStack client API for Java.

            Screenshot

            Project Spotlight

            TurnKey TWiki Appliance

            A TWiki appliance that is easy to use and lightweight.