Linux lsscsi: See List Of All SCSI / SATA Hard Disks and CD / DVD Drives

by on March 14, 2010 · 1 comment· LAST UPDATED October 3, 2012

in

How do I see attached scsi devices for my IBM Linux server powered by Red Hat Enterprise Linux 5 or 6? How do I list all sata hard disk names under Debian or Ubuntu Linux?

The Linux kernel version 2.6 and later uses sysfs. One can use sysfs to list all scsi devices and hosts attached to the server powered by Linux kernel 2.6.xx+.

Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsNone
Estimated completion timeN/A

The lsscsi command is handy tool to get all sort of information. You can find information about various transport being used in system such as ATA, Fibre channel (FC), IEEE 1394 (SBP), iSCSI: target only, SCSI Parallel Interface (SPI), Serial Attached SCSI (SAS), SATA, and USB.

Install lsscsi

Debian / Ubuntu Linux user type the following command to install lsscsi:
# apt-get install lsscsi
RHEL / CentOS Linux user type the following command
# yum install lsscsi
Sample outputs:

 
Loaded plugins: product-id, protectbase, rhnplugin
0 packages excluded due to repository protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package lsscsi.x86_64 0:0.23-2.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
====================================================================================================
 Package           Arch              Version                  Repository                       Size
====================================================================================================
Installing:
 lsscsi            x86_64            0.23-2.el6               rhel-x86_64-server-6             38 k
 
Transaction Summary
====================================================================================================
Install       1 Package(s)
 
Total download size: 38 k
Installed size: 0
Is this ok [y/N]: y
Downloading Packages:
lsscsi-0.23-2.el6.x86_64.rpm                                                 |  38 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : lsscsi-0.23-2.el6.x86_64                                                         1/1
Installed products updated.
  Verifying  : lsscsi-0.23-2.el6.x86_64                                                         1/1
 
Installed:
  lsscsi.x86_64 0:0.23-2.el6
 
Complete!
 

How do I use lsscsi command?

Simply type the following command:
$ lsscsi
Sample outputs:

[0:0:1:0]    cd/dvd  Slimtype COMBO SSC-2485K  5K06  /dev/sr0
[4:0:0:0]    disk    Adaptec  raid1-a          V1.0  /dev/sda
[4:1:0:0]    disk    FUJITSU  MAX3073RC        0104  -
[4:1:1:0]    disk    FUJITSU  MAX3073RC        0104

Where,

  1. [4:0:0:0] - raid1-a (/dev/sda) : My Adaptec based RAID 1 array.
  2. [4:1:0:0] and [4:1:1:0] : My two sas hard disks behind adaptec RAID 1 array.

To see generic device node name hidden behind RAID array, enter:
$ lsscsi -d
Sample outputs:

[0:0:1:0]    cd/dvd  Slimtype COMBO SSC-2485K  5K06  /dev/sr0   /dev/sg0
[4:0:0:0]    disk    Adaptec  raid1-a          V1.0  /dev/sda   /dev/sg1
[4:1:0:0]    disk    FUJITSU  MAX3073RC        0104  -         /dev/sg2
[4:1:1:0]    disk    FUJITSU  MAX3073RC        0104  -         /dev/sg3

Another output taken from my personal system:

[0:0:0:0]    disk    ATA      TOSHIBA MK5061GS MF00  /dev/sda
[1:0:0:0]    cd/dvd  MATSHITA BD-RE UJ232A     1.10  /dev/sr0
[2:0:0:0]    disk    ATA      ST9500420ASG     0004  /dev/sdb

Examples

To see disk size in human readable format, enter:
$ lsscsi -s
To see long format pass the -l option:
$ lsscsi -l
Sample outputs:

[0:0:0:0]    disk    ATA      TOSHIBA MK5061GS MF00  /dev/sda
  state=running queue_depth=31 scsi_level=6 type=0 device_blocked=0 timeout=30
[1:0:0:0]    cd/dvd  MATSHITA BD-RE UJ232A     1.10  /dev/sr0
  state=running queue_depth=1 scsi_level=6 type=5 device_blocked=0 timeout=30
[2:0:0:0]    disk    ATA      ST9500420ASG     0004  /dev/sdb
  state=running queue_depth=31 scsi_level=6 type=0 device_blocked=0 timeout=30

Options

Here are all options supported by lsscsi command:

    --classic|-c    alternate output similar to 'cat /proc/scsi/scsi'
    --device|-d     show device node's major + minor numbers
    --generic|-g    show scsi generic device name
    --help|-h       this usage information
    --hosts|-H      lists scsi hosts rather than scsi devices
    --kname|-k      show kernel name instead of device node name
    --list|-L       additional information output one
                    attribute=value per line
    --long|-l       additional information output
    --transport|-t  transport information for target or, if '--hosts'
                    given, for initiator
    --verbose|-v    output path names where data is found
    --version|-V    output version string and exit
           filter output list (def: '- - - -' (all))

A note about /proc/scsi/scsi

If you do not want to use or install the lsscsi command, try /proc/scsi/scsi as follows:
$ cat /proc/scsi/scsi
Sample outputs:

Attached devices:
Host: scsi0 Channel: 00 Id: 01 Lun: 00
  Vendor: Slimtype Model: COMBO SSC-2485K  Rev: 5K06
  Type:   CD-ROM                           ANSI  SCSI revision: 05
Host: scsi4 Channel: 00 Id: 00 Lun: 00
  Vendor: Adaptec  Model: raid1-a          Rev: V1.0
  Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi4 Channel: 01 Id: 00 Lun: 00
  Vendor: FUJITSU  Model: MAX3073RC        Rev: 0104
  Type:   Direct-Access                    ANSI  SCSI revision: 03
Host: scsi4 Channel: 01 Id: 01 Lun: 00
  Vendor: FUJITSU  Model: MAX3073RC        Rev: 0104
  Type:   Direct-Access                    ANSI  SCSI revision: 03

Check out related media


(Video.01: lsscsi command demo)

Recommend readings:

RHEL / Debian and friends comes with an older version. I recommend that you grab the latest version by visiting this url.

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 1 comment… read it below or add one }

1 santosh kumar April 5, 2014 at 9:06 am

give me scsi Linux installation

Reply

Leave a Comment

Tagged as: , , , , , , , , , ,

Previous Faq:

Next Faq: