search
HomeSystem TutorialLINUXDetailed explanation of Linux command lsscsi

Detailed explanation of Linux command lsscsi

Feb 11, 2024 pm 02:12 PM
linuxlinux tutoriallinux systemlinux commandshell scriptembeddedlinuxGetting started with linuxlinux learning

To understand the lsscsi command, first we need to understand what SCSI is and common hard disk interfaces and common hard disk parameters.

1. What is SCSI?

SCSI (Small Computer System Interface) is a complete data transfer protocol, which is mainly used to transfer commands, status and block data between the host and storage devices. Among various storage technologies, SCSI technology is the most important pillar.

The SCSI protocol is located between the operating system and external resources. It has a series of functional components. The operating system's I/O operations on external devices (such as disks, tapes, CD-ROMs, printers , etc.) can be implemented through the SCSI protocol. Typically, the SCSI protocol is embedded in the device driver or the host adapter's onboard logic.

Detailed explanation of Linux command lsscsi

2. Common hard disk interfaces

1. Hard drive with IDE interface

Its English name: Integrated Drive Electronics, the common 2.5-inch IDE hard disk interface, its original meaning refers to the hard disk drive that integrates the "hard disk controller" and the "disk body".

IDE represents a type of hard disk, but in actual applications, people are also accustomed to using IDE to refer to the earliest IDE type hard disk ATA-1. This type of interface has been eliminated with the development of interface technology. , and then developed into more types of hard disk interfaces, such as ATA, Ultra ATA, DMA, Ultra DMA and other interfaces, which are all IDE hard disks.

Its characteristics are: low price, strong compatibility, high cost performance, slow data transmission, does not support hot swapping, etc.

Detailed explanation of Linux command lsscsi

2. SCSI interface hard disk

SCSI is not an interface specifically designed for hard disks. It is a high-speed data transmission technology widely used on minicomputers.

The SCSI interface has the advantages of wide application range, multi-tasking, large bandwidth, low CPU usage, and hot-swappability. However, the higher price makes it difficult to be as popular as IDE hard drives, so SCSI hard drives are mainly used in medium and , high-end servers and high-end workstations.

Its characteristics are: high transmission rate, good reading and writing performance, can connect multiple devices, and can support hot swapping, but the price is relatively expensive.

Detailed explanation of Linux command lsscsi

3. SATA interface type

The English name is: Serial Advanced Technology Attachment. Hard drives using the SATA (Serial ATA) port are also called serial hard drives and are the future trend of PC hard drives.

Serial ATA uses a serial connection method. The Serial ATA bus uses an embedded clock signal and has stronger error correction capabilities. Compared with the past, its biggest difference is that it can transmit instructions (not just data). Check and automatically correct errors if found, which greatly improves the reliability of data transmission.

The serial interface also has the advantages of simple structure and support for hot swapping.

Detailed explanation of Linux command lsscsi

3. lsscsi command

lsscsi lists scsi/sata device information, such as hard drives and optical drives.

1. lsscsi command installation

-bash: lsscsi command not found
 
#Debian
apt-get install lsscsi
 
#Ubuntu
apt-get install lsscsi
 
#Alpine
apk add lsscsi
 
#Arch Linux
pacman -S lsscsi
 
#Kali Linux
apt-get install lsscsi
 
#CentOS
yum install lsscsi
 
#Fedora
dnf install lsscsi
 
#Raspbian
apt-get install lsscsi
 
#Docker
docker run cmd.cat/lsscsi lsscsi

2. lsscsi command English manual

Detailed command description address

https://sg.danny.cz/scsi/lsscsi.html
Detailed explanation of Linux command lsscsi

2. Command format

lsscsi command syntax:

lsscsi [选项] [H:C:T:L]

lsscsi command options:

Options meaning
-g Display SCSI common device file name
-k Display kernel name instead of device node name
-d Display the primary and secondary numbers of the device node
-H List the SCSI hosts currently connected to the system instead of the SCSI devices
-l Display additional information for each SCSI device (host)
-c Relative to the output of executing cat /proc/scsi/scsi command
-p Show additional data integrity (protection) information
-t Display transmission information
-L Display additional information in the form of "attribute name=value"
-v Output directory name when information is found
-y Assume that sysfs is mounted at the specified path instead of the default "/sys"
-s Display capacity size.
-c Display the default information with the full name.
-d Display the device primary and secondary device numbers.
-g Display the corresponding sg device name.
-H Display host controller list, -Hl, -Hlv.
-l Display related attributes, -ll,-llll=-L.
-v Display the directory where the device properties are located.
-x Display the lun number in hexadecimal.
-p Output DIF,DIX protection type.
-P Output valid protection mode information.
-i Display udev related attributes
-w Show WWN
-t Display corresponding transmission information (ATA, FC, SBP, ISCSI, SPI, SAS, SATA, USB), -Ht, -tl. (including sas address)

3. 结果含义

Detailed explanation of Linux command lsscsi

四、命令举例

lsscsi 列出所有 SCSI 设备:

peng@ubuntu:~$ lsscsi
[3:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0 
[32:0:0:0]   disk    VMware,  VMware Virtual S 1.0   /dev/sda 

lsscsi -L列出所有具有详细属性的 SCSI 设备:

peng@ubuntu:~$ lsscsi -L
[3:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0 
  device_blocked=0
  iocounterbits=32
  iodone_cnt=0x229
  ioerr_cnt=0x4
  iorequest_cnt=0x23a
  queue_depth=1
  queue_type=none
  scsi_level=6
  state=running
  timeout=30
  type=5
[32:0:0:0]   disk    VMware,  VMware Virtual S 1.0   /dev/sda 
  device_blocked=0
  iocounterbits=32
  iodone_cnt=0x37370
  ioerr_cnt=0x3
  iorequest_cnt=0x37370
  queue_depth=32
  queue_type=simple
  scsi_level=3
  state=running
  timeout=180
  type=0

lsscsi -s列出所有具有人类可读磁盘容量的 SCSI 设备:

peng@ubuntu:~$ lsscsi -s
[3:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0        -
[32:0:0:0]   disk    VMware,  VMware Virtual S 1.0   /dev/sda    536GB

五、其他

1. Linux下scsi相关文件节点

/proc/scsi/

peng@ubuntu:~$ cd /proc/scsi/
peng@ubuntu:/proc/scsi$ ls
device_info  mptspi  scsi  sg

peng@ubuntu:/proc/scsi$ cat scsi
Attached devices:
Host: scsi32 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware,  Model: VMware Virtual S Rev: 1.0 
  Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi3 Channel: 00 Id: 00 Lun: 00
  Vendor: NECVMWar Model: VMware SATA CD01 Rev: 1.00
  Type:   CD-ROM                           ANSI  SCSI revision: 05

/sys/class/scsi_host

peng@ubuntu:/sys/class/scsi_host$ ls
host0   host12  host16  host2   host23  host27  host30  host5  host9
host1   host13  host17  host20  host24  host28  host31  host6
host10  host14  host18  host21  host25  host29  host32  host7
host11  host15  host19  host22  host26  host3   host4   host8

/sys/class/scsi_device

peng@ubuntu:/sys/class/scsi_device$ ls
3:0:0:0  32:0:0:0

/sys/class/scsi_disk

peng@ubuntu:/sys/class/scsi_disk$ ls
32:0:0:0

/sys/class/scsi_generic

peng@ubuntu:/sys/class/scsi_generic$ ls
sg0  sg1

/sys/bus/scsi

peng@ubuntu:/sys/bus/scsi$ ls
devices  drivers  drivers_autoprobe  drivers_probe  uevent
peng@ubuntu:/sys/bus/scsi/devices$ ls
3:0:0:0   host11  host16  host20  host25  host3   host5  target3:0:0
32:0:0:0  host12  host17  host21  host26  host30  host6  target32:0:0
host0     host13  host18  host22  host27  host31  host7
host1     host14  host19  host23  host28  host32  host8
host10    host15  host2   host24  host29  host4   host9

其中target3:0:0

对应

host:bus:id:lun

2. Linux 开启 SCSI 日志调试功能

  • 1.编译选项中需开启 CONFIG_SCSI_LOGGING
Detailed explanation of Linux command lsscsi
  • 2.该编译选项说明
drivers/scsi/Kconfig:213
config SCSI_LOGGING
    bool "SCSI logging facility"
    depends on SCSI
    ---help---
      This turns on a logging facility that can be used to debug a number
      of SCSI related problems.

      If you say Y here, no logging output will appear by default, but you
      can enable logging by saying Y to "/proc file system support" and
      "Sysctl support" below and executing the command

      echo  > /proc/sys/dev/scsi/logging_level

      where  is a four byte value representing the logging type
      and logging level for each type of logging selected.

      There are a number of logging types and you can find them in the
      source at . The logging levels
      are also described in that file and they determine the verbosity of
      the logging for each logging type.

      If you say N here, it may be harder to track down some types of SCSI
      problems. If you say Y here your kernel will be somewhat larger, but
      there should be no noticeable performance impact as long as you have
      logging turned off.
  • 3.logging 类型源码文件位置(有说明)
-> drivers\scsi\scsi_logging.h
  • 4.使用说明
/*
 * Note - the initial logging level can be set here to log events at boot time.
 * After the system is up, you may enable logging via the /proc interface.
 */
unsigned int scsi_logging_level;
#if defined(CONFIG_SCSI_LOGGING)
EXPORT_SYMBOL(scsi_logging_level);
#endif

scsi_logging_level 被定义成int类型(32bit),该机制使用了30个bit,从低位到高位每3bit为一个logging level从SCSI_LOG_ERROR_SHIFT到SCSI_LOG_IOCTL_SHIFT(SCSI_LOG_XXX_SHIFT为不同level的移位数),每个level使用的bit数都是3,所以 SCSI_LOG_XXX_BITS 均为3

  • 5.scsi_logging_level 值可以在 boot 命令行设置也可以开启设备后在 /proc 文件系统中设置:
-1   - Enable scsi events to syslog.         // 开启所有scsi log
0    - Disable scsi events to syslog.        // 关闭所有scsi log

命令:

echo 0/-1 > /proc/sys/dev/scsi/logging_level

The above is the detailed content of Detailed explanation of Linux command lsscsi. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:良许Linux教程网. If there is any infringement, please contact admin@php.cn delete
Why is Windows commonly used for desktop computing and gaming?Why is Windows commonly used for desktop computing and gaming?Apr 27, 2025 am 12:01 AM

Windowsispreferredfordesktopcomputingandgamingdueto:1)itsvastsoftwareandgamelibrary,2)user-friendlyandcustomizableinterface,3)extensivehardwarecompatibility,and4)performanceoptimizationcapabilities,despitesomeresource-heavyandupdate-relatedissues.

The Future of Linux Software: Will Flatpak and Snap Replace Native Desktop Apps?The Future of Linux Software: Will Flatpak and Snap Replace Native Desktop Apps?Apr 25, 2025 am 09:10 AM

For years, Linux software distribution relied on native formats like DEB and RPM, deeply ingrained in each distribution's ecosystem. However, Flatpak and Snap have emerged, promising a universal approach to application packaging. This article exami

What are the differences in how Linux and Windows handle device drivers?What are the differences in how Linux and Windows handle device drivers?Apr 25, 2025 am 12:13 AM

The differences between Linux and Windows in handling device drivers are mainly reflected in the flexibility of driver management and the development environment. 1. Linux adopts a modular design, and the driver can be loaded and uninstalled dynamically. Developers need to have an in-depth understanding of the kernel mechanism. 2. Windows relies on the Microsoft ecosystem, and the driver needs to be developed through WDK and signed and certified. The development is relatively complex but ensures the stability and security of the system.

Compare and contrast the security models of Linux and Windows.Compare and contrast the security models of Linux and Windows.Apr 24, 2025 am 12:03 AM

The security models of Linux and Windows each have their own advantages. Linux provides flexibility and customizability, enabling security through user permissions, file system permissions, and SELinux/AppArmor. Windows focuses on user-friendliness and relies on WindowsDefender, UAC, firewall and BitLocker to ensure security.

How does hardware compatibility differ between Linux and Windows?How does hardware compatibility differ between Linux and Windows?Apr 23, 2025 am 12:15 AM

Linux and Windows differ in hardware compatibility: Windows has extensive driver support, and Linux depends on the community and vendors. To solve Linux compatibility problems, you can manually compile drivers, such as cloning RTL8188EU driver repository, compiling and installing; Windows users need to manage drivers to optimize performance.

What are the differences in virtualization support between Linux and Windows?What are the differences in virtualization support between Linux and Windows?Apr 22, 2025 pm 06:09 PM

The main differences between Linux and Windows in virtualization support are: 1) Linux provides KVM and Xen, with outstanding performance and flexibility, suitable for high customization environments; 2) Windows supports virtualization through Hyper-V, with a friendly interface, and is closely integrated with the Microsoft ecosystem, suitable for enterprises that rely on Microsoft software.

What are the main tasks of a Linux system administrator?What are the main tasks of a Linux system administrator?Apr 19, 2025 am 12:23 AM

The main tasks of Linux system administrators include system monitoring and performance tuning, user management, software package management, security management and backup, troubleshooting and resolution, performance optimization and best practices. 1. Use top, htop and other tools to monitor system performance and tune it. 2. Manage user accounts and permissions through useradd commands and other commands. 3. Use apt and yum to manage software packages to ensure system updates and security. 4. Configure a firewall, monitor logs, and perform data backup to ensure system security. 5. Troubleshoot and resolve through log analysis and tool use. 6. Optimize kernel parameters and application configuration, and follow best practices to improve system performance and stability.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment