Hardware configuration
Recognizing hardware on a current Linux system
General information and tools
dmesg
dmidecode
ipmi-tool
lshw
Machine
Hardware vendor/model
Bear in mind that DMI information is very dependent on the vendor's implementation, and is not always available.
On an HP desktop:
/sys/class/dmi/id/product_name
HP Compaq dc5800 Small Form Factor
/sys/class/dmi/id/product_version
On an IBM/Lenovo ThinkPad:
/sys/class/dmi/id/product_name
1872V2B
/sys/class/dmi/id/product_version
ThinkPad T43
Motherboard (mostly on desktops/laptops)
/sys/class/dmi/id/board_vendor
Hewlett-Packard
/sys/class/dmi/id/board_name
2820h
CPU
lscpu from the util-linux package:
$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 2
On-line CPU(s) list: 0,1
Thread(s) per core: 1
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 23
Stepping: 6
CPU MHz: 2533.000
BogoMIPS: 5053.73
L1d cache: 32K
L1i cache: 32K
L2 cache: 3072K
NUMA node0 CPU(s): 0,1
You can use /proc/cpuinfo as well but it requires more parsing.
"physical id" = socket#
"cpu cores" = cores
"core id" = core# (not linear! separate numbering per socket! for example, you have the IDs 0 1 9 10 per each socket on a 4-core Xeon)
"siblings" = threads
Individual parameters can be found in sysfs.
Number of CPU cores and threads
HP dc5800 / Core2Duo E7200:
/sys/devices/system/cpu/online
0-1
ProLiant DL360 G7 / Xeon E5620:
/sys/devices/system/cpu/online
0-15
Number of threads in each core (SMP n-way)
E7200 (1-way):
/sys/devices/system/cpu/cpu0/topology/thread_siblings_list
0
E5620 (2-way):
/sys/devices/system/cpu/cpu0/topology/thread_siblings_list
0,8
Clock (frequency) in kHz
Maximum/Minimum
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
1733000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
800000
Current (root only)
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
2533000
Frequency scaling governor
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
ondemand
Architecture
$ uname -p
x86_64
Supported features
$ grep -m1 ^flags /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm sse4_1 lahf_lm dts
RAM
/proc/meminfo
/sys/devices/system/node/node0/meminfo
free -m (parses /proc/meminfo...)
vmstat -s -S M
Storage
Disks and partitions
Generic, basic information about physical devices (works on old Linux versions as well)
$ cat /proc/partitions
major minor #blocks name
8 0 120060864 sda
8 1 71680 sda1
8 2 119987200 sda2
253 0 119986172 dm-0
253 1 26214400 dm-1
253 2 20971520 dm-2
253 3 2097152 dm-3
Block devices: physical location and hiearchy. Includes LVM (device-mapper) devices.
$ ls -l /sys/block/
total 0
lrwxrwxrwx 1 root root 0 Jan 12 11:43 dm-0 -> ../devices/virtual/block/dm-0
lrwxrwxrwx 1 root root 0 Jan 11 14:15 dm-1 -> ../devices/virtual/block/dm-1
lrwxrwxrwx 1 root root 0 Jan 11 14:15 dm-2 -> ../devices/virtual/block/dm-2
lrwxrwxrwx 1 root root 0 Jan 11 14:15 dm-3 -> ../devices/virtual/block/dm-3
lrwxrwxrwx 1 root root 0 Jan 11 14:15 sda -> ../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda
lrwxrwxrwx 1 root root 0 Jan 12 11:43 sr0 -> ../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0
The lsscsi command works with IDE and Serial ATA as well:
$ lsscsi -d
[0:0:0:0] disk ATA Maxtor 6Y120M0 YAR5 /dev/sda [8:0]
[1:0:0:0] cd/dvd ATAPI DVD D DH16D3S SH37 /dev/sr0 [11:0]
lsblk gives a nice detailed overview:
$ lsblk -a
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 114.5G 0 disk
|-sda1 8:1 0 70M 0 part /boot
`-sda2 8:2 0 114.4G 0 part
`-cr_sda2 (dm-0) 253:0 0 114.4G 0 crypt
|-system-home (dm-1) 253:1 0 25G 0 lvm /home
|-system-root (dm-2) 253:2 0 20G 0 lvm /
`-system-swap (dm-3) 253:3 0 2G 0 lvm [SWAP]
sr0 11:0 1 1024M 0 rom
Optional columns (very rare with Linux utilities!) - most of them are available for root only:
# lsblk -n -o NAME,KNAME,FSTYPE,UUID,SIZE,TYPE
sda sda 114.5G disk
|-sda1 sda1 ext4 f16c1a22-83d5-477f-b9c1-2ab6e51e2a84 70M part
`-sda2 sda2 crypto_LUKS 12c6a7c5-3aba-44d1-bf59-9ba9fcf2041d 114.4G part
`-cr_sda2 (dm-0) dm-0 LVM2_member POILkH-7nel-5wjA-8iZZ-vwYB-4WBr-9kgBpc 114.4G crypt
|-system-home (dm-1) dm-1 ext4 0e32fb87-3c8d-4e2b-b406-a6d035500188 25G lvm
|-system-root (dm-2) dm-2 ext4 3dc2fc2b-931e-492c-bd73-c1241e55c10e 20G lvm
`-system-swap (dm-3) dm-3 swap 16cb90d7-7d2f-4948-9b9b-a527e880d2bf 2G lvm
sr0 sr0 1024M rom
A way to determine ATA port to device mapping
Details from dmesg:
[ 1.092442] ata1.00: ATA-7: Maxtor 6Y120M0, YAR51HW0, max UDMA/133
[ 1.092121] ata2.00: ATAPI: ATAPI DVD D DH16D3S, SH37, max UDMA/100
Note that ataX numbering starts from 1.
In the example, ata1 maps to host0 in the SCSI naming hierarchy, which can be identified by looking at the unique_id entry:
$ for host in $(find /sys/devices/pci*/*/host* -prune); do [ -d "$host"/target* ] && ls -d "$host"/target*/*/block/*; done
/sys/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda
/sys/devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0
$ for host in $(find /sys/devices/pci*/*/host* -prune); do [ -d "$host"/target* ] && ls -1 "$host"/scsi_host/$(basename "$host")/unique_id; done
/sys/devices/pci0000:00/0000:00:1f.2/host0/scsi_host/host0/unique_id
/sys/devices/pci0000:00/0000:00:1f.2/host1/scsi_host/host1/unique_id
$ cat /sys/devices/pci0000\:00/0000\:00\:1f.2/host0/scsi_host/host0/unique_id
1
There is a separate tree for ata* devices in sysfs, without reference to the physical bus/host mapping.
$ ls -1d /sys/devices/pci*/*/ata*
/sys/devices/pci0000:00/0000:00:1f.2/ata1
/sys/devices/pci0000:00/0000:00:1f.2/ata2
/sys/devices/pci0000:00/0000:00:1f.5/ata3
/sys/devices/pci0000:00/0000:00:1f.5/ata4
Filesystems
df -PTh -t ext3 -t ext4