The hwdetect utility performs basic hardware detection functions that are typically performed by using SMBIOS and a PCI scan. This utility contains options that can be used to either dump all of the hardware information to an output file or to query hardware information and return values that set the errorlevel environment variable or the return code, for example $?.
hwdetect includes basic hardware scan functions and more complex PCI device detection options. The basic hardware scan functions can be used one at a time only. The PCI device detection functions, however, can be combined or used more than once on the same command line to produce a query based on multiple restrictions.
hwdetect [-s|-i|-p|--m=machinetype] -f=filename
Parameter | Description | Example |
---|---|---|
-s |
Determines if the target server is an Lenovo System x, xSeries, or BladeCenter server.
The return values are:
|
./hwdetect -s if [ $? eq 1 ]; then echo Perform non-Lenovo equipment specific steps here. else echo Perform Lenovo equipment specific steps here. fi |
-i |
Dumps all available information about the system
hardware to the screen in a .ini file format.
You can use the -f parameter to send this information
to a file. A return code of zero indicates success. All other return codes indicate an error. |
./hwdetect -i |
-f=filename |
Directs the output to the indicated file. This
parameter can be used in conjunction with the -i or -p parameters. A return code of 254 indicates that HWDETECT was unable to open the specified file. |
./hwdetect -i -f=hwdetect.out cat hwdetect.out | grep Bus_Number.21 = 41 |
--m=machinetype |
Compares the machine type of the current system
to the specified machine type. Return codes:
|
./hwdetect -m=8676 if [ $? eq 8676 ]; then echo It is a Lenovo system. else echo It is not a Lenovo system. |
You can also use hwdetect to inventory PCI devices on the target system.
hwdetect [--vid=vendor_id|--did=device_id|--svid=sub-vendor_id| --sdid=sub-device_id|--bn=bus_number|--dn=device_number|--add=number]
Parameter | Description | Example |
---|---|---|
--vid=vendor_id |
Searches for PCI devices with the indicated hexadecimal vendor ID. | ./hwdetect --vid=40 echo "Found $? matches..." |
--did=device_id |
Searches for PCI devices with the indicated hexadecimal device ID. | ./hwdetect --did=41 echo "Found $? matches..." |
--svid=sub-vendor_id |
Searches for PCI devices with the indicated hexadecimal sub-vendor ID. | ./hwdetect --svid=42 echo "Found $? matches..." |
--sdid=sub-device_id |
Searches for PCI devices with the indicated hexadecimal sub-device ID. | ./hwdetect --sdid=43 echo "Found $? matches..." |
--bn=bus_number |
Starts the search at the indicated decimal bus number. | ./hwdetect --bn=44 echo "Found $? matches..." |
--dn=device_number |
Starts the search at the indicated decimal device number. | ./hwdetect --dn=45 echo "Found $? matches..." |
--add=number |
Adds the specified decimal value to the return value before exiting. | ./hwdetect --vid=46 --add=1 echo "Found $? - 1 matches..." |
[System] Machine_Type=8674 Model_Number=42X Serial_Number=78Z9506 Product_Name=eserver xSeries 330 BIOS_version=1.04 BIOS_Build_Level=EME112A BIOS_DATE=06/28/2002 BIOS_Manufacturer=IBM BIOS_Language=US Number_Of_Enclosures=1 Enclosure_Type.0=23 Processor_Slots=2 Active_Processors=1 Processor_Family.0=17 Processor_Speed_MHz.0=1400 Processor_X64 = TRUE Total_Enabled_Memory_Mb=256 ROM_Diagnostics_Build_Level=EME112A ISMP_Build_Level=BR8T30A RSA_Build_Level=GEE834A System_UUID = 8030E01060F010B010605090D0A020F0 Blade_Chassis_UUID = 0F020A0D0900F00F020A0D0900F00F02 Blade_Slot = 02 [PCI] Total_Number_Devices=10 Bus_Number.0=0 Device_Number.0=1 Function_Number.0=0 Class_Code.0=0000 Revision.0=0 Header_Type.0=0 Vendor_ID.0=5333 Device_ID.0=8A22 Subvendor_ID.0=1014 Subdevice_ID.0=01C5 Bus_Number.1=0 Device_Number.1=2 Function_Number.1=0 Class_Code.1=0000 Revision.1=0 Header_Type.1=0 Vendor_ID.1=8086 Device_ID.1=1229 Subvendor_ID.1=1014 Subdevice_ID.1=105C
System_Machine_Type = 8674 System_Model_Number = 42X System_Serial_Number = 78Z9506 PCI_Bus_Number.0 = 0 PCI_Device_Number.0 = 1 ...