{
    "mode": "man",
    "parameter": "SG_MAP",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/SG_MAP/8/json",
    "generated": "2026-06-14T13:17:50Z",
    "synopsis": "sgmap [-a] [-h] [-i] [-n] [-scd] [-sd] [-sr] [-st] [-V] [-x]",
    "sections": {
        "NAME": {
            "content": "sgmap - displays mapping between Linux sg and other SCSI devices\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "sgmap [-a] [-h] [-i] [-n] [-scd] [-sd] [-sr] [-st] [-V] [-x]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Sometimes  it  is  difficult  to determine which SCSI device a sg device name (e.g. /dev/sg0)\nrefers to. This command loops through the sg devices and finds the corresponding  SCSI  disk,\ncdrom  or tape device name (if any). Scanners are an example of SCSI devices that have no al‐\nternate SCSI device name apart from their sg device name.\n\nThis utility is deprecated and has not been updated for years, only very obvious bugs will be\nfixed.  Unless  a very old version of Linux is being used (e.g.  2.4 series or earlier), then\nplease use a utility like lsscsi(8) or the facilities offered by udev(8).\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-a",
                    "content": "/dev/sgb,  etc. Default is numeric scan.  Note that sg device nodes with an alphabeti‐\ncal index have been deprecated since the Linux kernel 2.2 series.\n",
                    "flag": "-a"
                },
                {
                    "name": "-h",
                    "content": "",
                    "flag": "-h"
                },
                {
                    "name": "-i",
                    "content": "devices that are found.\n",
                    "flag": "-i"
                },
                {
                    "name": "-n",
                    "content": "etc. Default is numeric scan\n",
                    "flag": "-n"
                },
                {
                    "name": "-scd",
                    "content": ""
                },
                {
                    "name": "-sd",
                    "content": ""
                },
                {
                    "name": "-sr",
                    "content": ""
                },
                {
                    "name": "-st",
                    "content": ""
                },
                {
                    "name": "-V",
                    "content": "",
                    "flag": "-V"
                },
                {
                    "name": "-x",
                    "content": "<bus> <scsiid> <lun> <scsitype>\n",
                    "flag": "-x"
                }
            ]
        },
        "NOTES": {
            "content": "If  no options starting with \"-s\" are given then the mapping to all SCSI disk, cdrom and tape\ndevice names is shown.\n\nIf the device file system (devfs) is present a line noting this is output. The \"native\" devfs\nscsi  hierarchy  makes  the relationship between a sg device name and any corresponding disk,\ncdrom or tape device name easy to establish. This replaces the need for this command. However\nmany  applications  will  continue  to  look for Linux SCSI device names in their traditional\nplaces. [Devfs supplies a compatibility daemon called devfsd whose default configuration adds\nback the Linux device names in their traditional positions.\n\nQuite  often  the  mapping information can be derived by observing the output of the command:\n\"cat /proc/scsi/scsi\".  However if devices have been added since boot this can be deceptive.\n\nIn the Linux kernel 2.6 series something close to the mapping shown by this  utility  can  be\nfound  by  analysing  sysfs. The main difference is that sysfs analysis will show the mapping\nbetween sg nodes and other SCSI device nodes in terms of major and minor numbers. While major\n8,  minor  16 will usually be /dev/sdb this is not necessarily so. Facilities associated with\nudev may assign major 8, minor 16 some other device node name. This  version  of  sgmap  has\nbeen  extended  to  cope  with sparse disk device node names of the form \"/dev/sd<str>\" where\n<str> can be one of [a-z,aa-zz,aaa-zzz]. See the sgmap26 utility  for  a  more  precise  way\n(i.e.  less  directory  scanning) for mapping between sg device names and higher level names;\nincluding finding user defined names.\n\nThis utility was written at a time when hotplugging of SCSI  devices  was  not  supported  in\nLinux.  It used a simple algorithm to scan sg device nodes in ascending numeric or alphabeti‐\ncal order, stopping after there were 5 consecutive errors.\n\nIn the Linux kernel 2.6 series, this utility uses sysfs to find which sg device nodes are ac‐\ntive  and  only  checks those. Hence there can be large \"holes\" in the numbering of sg device\nnodes (e.g. after an adapter has been removed) and still all active sg device nodes  will  be\nlisted.  This utility assumes that sg device nodes are named using the normal conventions and\nsearches from /dev/sg0 to /dev/sg4095 inclusive.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "My system has a SCSI disk, a cd writer and a dvd player:\n$ sgmap\n# Note: the devfs pseudo file system is present\n/dev/sg0  /dev/sda\n/dev/sg1  /dev/sr0\n/dev/sg2  /dev/sr1\n\nIn order to find which sg device name corresponds to the disk:\n$ sgmap -sd\n# Note: the devfs pseudo file system is present\n/dev/sg0  /dev/sda\n/dev/sg1\n/dev/sg2\n\nThe \"-x\" option gives the following output:\nsgmap -x\n# Note: the devfs pseudo file system is present\n/dev/sg0  1 0 1 0  0  /dev/sda\n/dev/sg1  2 0 4 0  5  /dev/sr0\n/dev/sg2  2 0 6 0  5  /dev/sr1\n\nWhen a SCSI scanner is added the output becomes:\n$ sgmap\n# Note: the devfs pseudo file system is present\n/dev/sg0  /dev/sda\n/dev/sg1  /dev/sr0\n/dev/sg2  /dev/sr1\n/dev/sg3\n\nBy process of elimination /dev/sg3 must be the scanner.\n",
            "subsections": []
        },
        "EXIT STATUS": {
            "content": "The exit status of sgmap is 0 when it is successful.  Otherwise  see  the  sg3utils(8)  man\npage.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Written by Douglas Gilbert\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "Report bugs to <dgilbert at interlog dot com>.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright © 2000-2013 Douglas Gilbert\nThis software is distributed under the GPL version 2. There is NO warranty; not even for MER‐\nCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "sgmap26(8) , scsiinfo(8) , scsidev(8) , devfsd(8) , lsscsi(8) , udev(7)\n\n\n\nsg3utils-1.36                                May 2013                                     SGMAP(8)",
            "subsections": []
        }
    },
    "summary": "sgmap - displays mapping between Linux sg and other SCSI devices",
    "flags": [
        {
            "flag": "-a",
            "long": null,
            "arg": null,
            "description": "/dev/sgb, etc. Default is numeric scan. Note that sg device nodes with an alphabeti‐ cal index have been deprecated since the Linux kernel 2.2 series."
        },
        {
            "flag": "-h",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-i",
            "long": null,
            "arg": null,
            "description": "devices that are found."
        },
        {
            "flag": "-n",
            "long": null,
            "arg": null,
            "description": "etc. Default is numeric scan"
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-V",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-x",
            "long": null,
            "arg": null,
            "description": "<bus> <scsiid> <lun> <scsitype>"
        }
    ],
    "examples": [
        "My system has a SCSI disk, a cd writer and a dvd player:",
        "$ sgmap",
        "# Note: the devfs pseudo file system is present",
        "/dev/sg0  /dev/sda",
        "/dev/sg1  /dev/sr0",
        "/dev/sg2  /dev/sr1",
        "In order to find which sg device name corresponds to the disk:",
        "$ sgmap -sd",
        "# Note: the devfs pseudo file system is present",
        "/dev/sg0  /dev/sda",
        "/dev/sg1",
        "/dev/sg2",
        "The \"-x\" option gives the following output:",
        "sgmap -x",
        "# Note: the devfs pseudo file system is present",
        "/dev/sg0  1 0 1 0  0  /dev/sda",
        "/dev/sg1  2 0 4 0  5  /dev/sr0",
        "/dev/sg2  2 0 6 0  5  /dev/sr1",
        "When a SCSI scanner is added the output becomes:",
        "$ sgmap",
        "# Note: the devfs pseudo file system is present",
        "/dev/sg0  /dev/sda",
        "/dev/sg1  /dev/sr0",
        "/dev/sg2  /dev/sr1",
        "/dev/sg3",
        "By process of elimination /dev/sg3 must be the scanner."
    ],
    "see_also": [
        {
            "name": "sgmap26",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/sgmap26/8/json"
        },
        {
            "name": "scsiinfo",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/scsiinfo/8/json"
        },
        {
            "name": "scsidev",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/scsidev/8/json"
        },
        {
            "name": "devfsd",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/devfsd/8/json"
        },
        {
            "name": "lsscsi",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/lsscsi/8/json"
        },
        {
            "name": "udev",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/udev/7/json"
        }
    ]
}