Using the Command 'systool' to Extract System Device Information (with examples)
- Linux
- December 17, 2024
The systool
command is a powerful utility part of the sysfs
package that allows users to obtain detailed information about system devices by accessing the SysFS (System File System) interface in Linux. It’s particularly useful for system administrators and developers who need to get insights into the hardware and drivers of their systems without diving too deep into the filesystem manually.
Use case 1: List All Attributes of Devices of a Bus
Code:
systool -b pci -v
Motivation:
Understanding the attributes of devices on a specific bus, such as PCI (Peripheral Component Interconnect), is crucial for diagnosing hardware issues or optimizing the configurations of servers and workstations. By listing all device attributes on a specific bus, administrators can gather comprehensive details necessary for troubleshooting or enhancing performance.
Explanation:
-b pci
: This argument specifies the bus type you are interested in. Thepci
keyword signifies that you want information about devices connected via the PCI bus.-v
: The verbose option is used to display additional details, offering more comprehensive output about each device connected to the specified bus.
Example Output:
Device = "0000:00:1f.2"
Class = "IDE interface"
Device = "82801HM/HEM"
Vendor = "Intel Corporation"
Driver = "ata_piix"
...
Device = "0000:00:1b.0"
Class = "Audio device"
Device = "82801H (ICH8 Family)"
Vendor = "Intel Corporation"
Driver = "snd_hda_intel"
...
The output illustrates various devices controlled by the PCI bus, showing their class, vendor, specific model, and the driver in use. This kind of detail is invaluable for compatibility checks and performance tuning.
Use case 2: List All Attributes of a Class of Devices
Code:
systool -c block -v
Motivation:
Accessing all attributes of a particular class of devices, such as block devices (which include hard drives, USB drives, etc.), is important for those managing storage systems. The detailed listing aids in verifying device health, monitoring capacity, and ensuring correct driver installation.
Explanation:
-c block
: This argument specifies the class of devices you’re interested in. Theblock
keyword indicates a focus on block devices like storage disks.-v
: Again, the verbose option provides more in-depth information for each device of the specified class.
Example Output:
Class = "block"
Device = "sda"
size = "500107862016"
model = "WDC WD5000AAKX-08U"
vendor = "ATA"
...
Device = "sdb"
size = "250059350016"
model = "Samsung SSD 860"
vendor = "ATA"
...
This output is useful for quick checks on all block devices, showing attributes such as size, model, and vendor, which can be essential for system audits or performance assessments.
Use case 3: Show Only Device Drivers of a Bus
Code:
systool -b usb -D
Motivation:
Seeing just the device drivers associated with a particular bus, like USB, is particularly helpful when debugging driver-related issues. It helps system administrators identify which drivers are loaded for devices on the USB bus and ensures that all necessary drivers are present and functioning.
Explanation:
-b usb
: This argument selects the USB bus to help filter devices that interact via USB connections.-D
: The device drivers option restricts the output to only show drivers for devices on the selected bus, rather than all attributes.
Example Output:
Driver = "usb-storage"
Driver = "usbhid"
Driver = "uvcvideo"
...
By listing only the drivers, it becomes easier to manage and update specific drivers relevant to the USB bus, thereby enhancing system stability and performance.
Conclusion:
The systool
command offers a comprehensive view of device attributes and drivers on Linux systems by leveraging the SysFS interface. Its ability to drill down into specific buses and classes of devices and its flexibility with output options make it an indispensable tool for system administration and hardware diagnostics. Whether checking device details, verifying installed drivers, or optimizing system components, systool
serves as a crucial component of system management in Linux environments.