Friday, June 12, 2009

lsscsi and systool

The lspci and lsusb commands are familiar to me, but lsscsi was unfamiliar. Written by Doug Gilbert, it provides information about SCSI devices by scanning the sysfs pseudo file system. The author maintained a web page (now defunct) that provided useful information about lsscsi, including some detailed descriptions of the SCSI subsystem information available. Fortunately, a copy resides here. Here's a sample listing from my system That also shows the generic SCSI device names (note that command can be run as a regular user) :

$ lsscsi -g
[0:0:0:0] disk ATA ST3250624A 3.AA /dev/sda /dev/sg0
[0:0:1:0] disk ATA Maxtor 6L200P0 BAH4 /dev/sdb /dev/sg1

[1:0:0:0] disk ATA Maxtor 6Y250P0 YAR4 /dev/sdc /dev/sg2

[1:0:1:0] cd/dvd HL-DT-ST DVD-RAM GH22LP20 1.02 /dev/sr0 /dev/sg3
[2:0:0:0] disk Seagate FreeAgent 102D /dev/sdd /dev/sg5
[3:0:0:0] cd/dvd SONY DVD RW DRU-810A 1.0a /dev/sr1 /dev/sg4
[4:0:0:0] disk ST910082 4AS 0000 /dev/sde /dev/sg6

The systool has been around for a while and has a Website. It's a utility developed for the sysfs virtual filesystem used since Linux kernel 2.5. The project's overall goal is to develop diagnostic tools for Linux and the site has several examples.

One use of systool is to reveal what option settings have been applied to kernel modules . For example, to see information about the libata module (note that it too can be run by a regular user):

$ systool -a -v -m libata
Module = "libata"
initstate = "live"
refcnt = "3"

srcversion = "9BD5A7BE268657853F9CEF1"
version = "3.00"

acpi_gtf_filter = "7"

allow_tpm = "0"

ata_probe_timeout = "0"
atapi_dmadir = "0"

atapi_enabled = "1"

atapi_passthru16 = "1"

dma = "7"

fua = "0"

ignore_hpa = "0"

noacpi = "0"

Sadly, many of these options are not well documented, even in the source code. Even when some comments exist, they are cryptic and could use a decent reference. For example, the allow_tpm option is described with modinfo only to the extent that it can be enabled or disable. There is some discussion of it in the source code, but WTF is it? It appears to be an acronym for Trusted Platform Module, part of software developed by TCG (the Trusted Computing Group). A TPM is a microcontroller on a motherboard used to store keys, passwords and digital certificates, i.e. a hardware-based security device. Why do Linux users care? It seems that a bit in the ATA identify data was re-assigned to TCG and could cause a serious problem for the Linux libata driver since a TGC-enabled drive would trigger 32bit I/O on some systems. Alan Cox submitted a patch to "fix" this by dis-allowing this bit on TCG-enabled drives, causing the system to "opt out" of complying with TCG "security/DRM" features. It does alert the user that they may not have full use of the device. It also was necessary to implement this feature because manufacturers of Linux-run devices may legitimately choose to implement DRM in their devices. Some module options for libata are set from the kernel command line (see kernel-options.txt in the kernel source Documentation). There's also a libATA FAQ which includes info on "Intel combined mode" explaining why your drives are accessed at wrong/different speeds and how to fix that (try combined_mode=libata on the kernel command line).

No comments: