LoginSignup
2
1

【Linux】ハードウェア系確認コマンド

Last updated at Posted at 2022-05-27

Linux-OS上で確認できるHW周りの情報を取得するコマンドメモ。

HW情報確認コマンド

lshwで見られるが、出力がとても長くなる。
よく使うHW情報を確認するなら、dmidecodeコマンド。
これもそのまま打つとずらっと出てくるが、tオプションで情報を指定できる。メーカーだけでなく型番やらシリアルも確認できちゃう。

[dango@host01 ~]# /usr/sbin/dmidecode -t system
# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.4.0 present.
# SMBIOS implementations newer than version 3.2.0 are not
# fully supported by this version of dmidecode.

Handle 0x0082, DMI type 1, 27 bytes
System Information
        Manufacturer: HPE
        Product Name: ProLiant DL360 Gen10
        Version: Not Specified
        Serial Number: JPNXXXXXX
        UUID: 39383250-3834-504a-4e31-XXXXXXXXXXX
        Wake-up Type: Power Switch
        SKU Number: PXXXXX-XXX
        Family: ProLiant

Handle 0x00CD, DMI type 32, 11 bytes
System Boot Information
        Status: No errors detected

[dango@host01 ~]#

BIOSは以下。Firmのversionもみれる。

[dango@host01 ~]# /usr/sbin/dmidecode -t bios
# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.4.0 present.
# SMBIOS implementations newer than version 3.2.0 are not
# fully supported by this version of dmidecode.

Handle 0x0002, DMI type 0, 26 bytes
BIOS Information
        Vendor: HPE
        Version: U46
        Release Date: 08/11/2022
        Address: 0xF0000
        Runtime Size: 64 kB
        ROM Size: 64 MB
        Characteristics:
                PCI is supported
                PNP is supported
                BIOS is upgradeable
                BIOS shadowing is allowed
                ESCD support is available
                Boot from CD is supported
                Selectable boot is supported
                EDD is supported
                5.25"/360 kB floppy services are supported (int 13h)
                5.25"/1.2 MB floppy services are supported (int 13h)
                3.5"/720 kB floppy services are supported (int 13h)
                Print screen service is supported (int 5h)
                8042 keyboard services are supported (int 9h)
                Serial services are supported (int 14h)
                Printer services are supported (int 17h)
                CGA/mono video services are supported (int 10h)
                ACPI is supported
                USB legacy is supported
                BIOS boot specification is supported
                Function key-initiated network boot is supported
                Targeted content distribution is supported
                UEFI is supported
        BIOS Revision: 1.64
        Firmware Revision: 2.72

CPU

[dango@raspi01 ~]# cat /proc/cpuinfo
processor       : 0
BogoMIPS        : 108.00
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd08
CPU revision    : 3

processor       : 1
BogoMIPS        : 108.00
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd08
CPU revision    : 3

processor       : 2
BogoMIPS        : 108.00
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd08
CPU revision    : 3

processor       : 3
BogoMIPS        : 108.00
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd08
CPU revision    : 3

Hardware        : BCM2835
Revision        : c03114
Serial          : 1000000080401a8a
Model           : Raspberry Pi 4 Model B Rev 1.4

メモリ

[dango@raspi01 ~]# cat /proc/meminfo
MemTotal:        3881060 kB
MemFree:          218228 kB
MemAvailable:    3299576 kB
Buffers:          123048 kB
Cached:          2965772 kB
SwapCached:          100 kB
Active:          2150524 kB
Inactive:        1147088 kB
Active(anon):       3656 kB
Inactive(anon):   196816 kB
Active(file):    2146868 kB
Inactive(file):   950272 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       1048572 kB
SwapFree:        1043196 kB
Dirty:                 4 kB
Writeback:             0 kB
AnonPages:        207500 kB
Mapped:           127132 kB
Shmem:              3552 kB
KReclaimable:     176116 kB
Slab:             262560 kB
SReclaimable:     176116 kB
SUnreclaim:        86444 kB
KernelStack:        4320 kB
PageTables:         4696 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     2989100 kB
Committed_AS:    1014316 kB
VmallocTotal:   133143592960 kB
VmallocUsed:       21884 kB
VmallocChunk:          0 kB
Percpu:             3216 kB
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:         0 kB
FilePmdMapped:         0 kB
CmaTotal:         327680 kB
CmaFree:          109336 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB

メインメモリとスワップの使用量を簡易的に調べるならfree -htコマンド

ディスク

[dango@raspi01 ~]# cat /proc/diskstats
   7       0 loop0 14 0 34 1 0 0 0 0 0 16 1 0 0 0 0 0 0
   7       1 loop1 123 0 4384 572 0 0 0 0 0 296 572 0 0 0 0 0 0
   7       2 loop2 113 0 2926 239 0 0 0 0 0 284 239 0 0 0 0 0 0
   7       3 loop3 58 0 2198 473 0 0 0 0 0 392 473 0 0 0 0 0 0
   7       4 loop4 1005 0 45298 1483 0 0 0 0 0 3896 1483 0 0 0 0 0 0
   7       5 loop5 1038 0 56160 973 0 0 0 0 0 2972 973 0 0 0 0 0 0
   7       6 loop6 326 0 8404 894 0 0 0 0 0 1152 894 0 0 0 0 0 0
   7       7 loop7 232 0 8792 348 0 0 0 0 0 800 348 0 0 0 0 0 0
 179       0 mmcblk0 78621 12115 5928704 461151 321865 303307 26572025 19383750 0 1953408 20532003 19445 421 44908200 687100 0 0
 179       1 mmcblk0p1 217 146 11504 1444 1681 1062 597089 204423 0 18908 207247 6 6 294736 1379 0 0
 179       2 mmcblk0p2 78287 11969 5913576 459616 320184 302245 25974936 19179327 0 1948548 20324663 19439 415 44613464 685720 0 0
   8       0 sda 130 0 6304 734 0 0 0 0 0 536 734 0 0 0 0 0 0
   8       1 sda1 74 0 4192 459 0 0 0 0 0 316 459 0 0 0 0 0 0
   7       8 loop8 115 0 4394 585 0 0 0 0 0 544 585 0 0 0 0 0 0
   7       9 loop9 115 0 4390 700 0 0 0 0 0 668 700 0 0 0 0 0 0
   7      10 loop10 53 0 2128 1507 0 0 0 0 0 584 1507 0 0 0 0 0 0
   7      11 loop11 152 0 5248 1392 0 0 0 0 0 708 1392 0 0 0 0 0 0
   7      12 loop12 869 0 56354 2191 0 0 0 0 0 4004 2191 0 0 0 0 0 0
   7      13 loop13 1164 0 28574 1950 0 0 0 0 0 1612 1950 0 0 0 0 0 0
   7      14 loop14 183 0 2740 563 0 0 0 0 0 500 563 0 0 0 0 0 0
   7      15 loop15 112 0 2952 82 0 0 0 0 0 136 82 0 0 0 0 0 0
   7      16 loop16 5962 0 428672 1147 0 0 0 0 0 24512 1147 0 0 0 0 0 0
   7      17 loop17 18 0 102 43 0 0 0 0 0 52 43 0 0 0 0 0 0
   7      18 loop18 31 0 556 121 0 0 0 0 0 180 121 0 0 0 0 0 0
   7      19 loop19 14 0 52 1 0 0 0 0 0 16 1 0 0 0 0 0 0
   7      20 loop20 12 0 40 1 0 0 0 0 0 24 1 0 0 0 0 0 0
   7      21 loop21 41 0 686 515 0 0 0 0 0 532 515 0 0 0 0 0 0
   7      22 loop22 48 0 710 479 0 0 0 0 0 504 479 0 0 0 0 0 0
   7      23 loop23 343 0 7414 26 0 0 0 0 0 372 26 0 0 0 0 0 0
   7      24 loop24 208 0 6598 13 0 0 0 0 0 308 13 0 0 0 0 0 0
   7      25 loop25 676 0 43852 69 0 0 0 0 0 2508 69 0 0 0 0 0 0
   7      26 loop26 336 0 7330 20 0 0 0 0 0 404 20 0 0 0 0 0 0
   7      27 loop27 247 0 11076 20 0 0 0 0 0 528 20 0 0 0 0 0 0

ディスク空き容量はdf -Hコマンド、ディレクトリごとのディスク使用量はdu -h /XXXコマンド、パーティション情報はlsblkコマンドで確認できる。

IF情報確認コマンド

認識されているIF情報はifconfigip でもいいが、物理/論理/仮想含めたデバイス全一覧を取得したい場合は
ls /sys/class/net/ で確認できる。
ボンディングIFのみであればls /proc/net/bonding/
ブリッジデバイスはbrctl show

[root@dango01 ~]# ls -l /sys/class/net/
bond0
bond0.1111
ens0
ens1

物理的にマシンに刺さっているデバイス名のみ欲しい場合は以下。

[root@dango01 ~]# for DEV in `find /sys/devices -name net | grep -v virtual`; do ls $DEV/; done
ens0
ens1



ethtoolを使うとIFの状態を確認できる。

[root@dango01 ~]$ ethtool ens0
Settings for ens0:
        Supported ports: [ FIBRE ]
        Supported link modes:   Not reported
        Supported pause frame use: Symmetric
        Supports auto-negotiation: No
        Supported FEC modes: Not reported
        Advertised link modes:  Not reported
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Advertised FEC modes: Not reported
        Speed: 25000Mb/s
        Duplex: Full
        Port: FIBRE
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: off
Cannot get wake-on-lan settings: Operation not permitted
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes
[root@dango01 ~]$
[root@dango01 ~]$ ethtool ens1
Settings for ens1:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: Symmetric
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: Symmetric
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: on (auto)
Cannot get wake-on-lan settings: Operation not permitted
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes
[root@dango01 ~]$

モノが対応していれば、-mを付けることでモジュールの詳細を確認できる。

NICのドライバ情報確認

dmesg | grep インターフェース名
でドライバ確認。

[root@dango01 ~]# dmesg | grep ens0
[   16.397642] ice 0000:0f:00.0 ens0: already using mac b4:96:XX:XX:XX:XX
[   16.719498] ice 0000:0f:00.0 ens0: NIC Link is up 25 Gbps, Flow Control: Unknown
[   16.727262] 8021q: adding VLAN 0 to HW filter on device ens0
[   16.739408] bond0: Enslaving ens0 as a backup interface with an up link

⇒iceドライバが使われている。

[root@dango01 ~]# dmesg | grep ens1
[   18.381323] 8021q: adding VLAN 0 to HW filter on device ens1
[   18.387455] bond2: Enslaving ens1 as a backup interface with a down link
[   22.113002] igb 0000:48:00.0 ens1: igb: ens1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
[   22.208608] bond2: link status up for interface ens1, enabling it in 10000 ms

⇒igbドライバが使われている。
modinfo ドライバ名
で確認。

[root@dango01 ~]# modinfo ice
filename:       /lib/modules/3.10.0-1160.el7.x86_64/kernel/drivers/net/ethernet/intel/ice/ice.ko.xz
version:        0.7.2-k
license:        GPL v2
description:    Intel(R) Ethernet Connection E800 Series Linux Driver
author:         Intel Corporation, <linux.nics@intel.com>
rhelversion:    7.9
[root@dango01 ~]# modinfo igb
filename:       /lib/modules/3.10.0-1160.el7.x86_64/kernel/drivers/net/ethernet/intel/igb/igb.ko.xz
version:        5.6.0-k
license:        GPL v2
description:    Intel(R) Gigabit Ethernet Network Driver
author:         Intel Corporation, <e1000-devel@lists.sourceforge.net>
retpoline:      Y
rhelversion:    7.9

-F versionやら-F descriptionでパラメータの指定可。

(おまけ)OS基本情報

カーネルの起動オプション確認。
GRUBなどのブートローダによってカーネルに渡されるパラメータ。

[root@host01 ~]# cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-3.10.0-1160.el7.x86_64 root=UUID=b91a1330-4dce-478a-8857-da1f37a1XXXX ro crashkernel=auto biosdevname=0 console=ttyS0,115200 net.ifnames=1

カーネルのバージョン確認

[root@host01 ~]# uname -r
3.10.0-1160.el7.x86_64

CentOS/RHELであれば

[dango@host01 ~]$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

でOSバージョンの確認ができるが、
/etc/redhat-releaseはファイルで、このファイルが含まれるパッケージを調べたのが以下。割と色々見れる。

[root@host01 ~]$ rpm -qif /etc/redhat-release
Name        : centos-release
Version     : 7
Release     : 9.2009.1.el7.centos
Architecture: x86_64
Install Date: 2020年10月04日 16時54分09秒
Group       : System Environment/Base
Size        : 44787
License     : GPLv2
Signature   : RSA/SHA256, 2020年12月03日 01時35分28秒, Key ID 24c6a8a7f4a80eb5
Source RPM  : centos-release-7-9.2009.1.el7.centos.src.rpm
Build Date  : 2020年11月24日 00時08分41秒
Build Host  : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
Summary     : CentOS Linux release file
Description :
CentOS Linux release files

ceontos-releaseというパッケージがあることがわかる。
パッケージに含まれるファイルをみてみる。

[root@host01 ~]$ rpm -ql centos-release
/etc/centos-release
/etc/centos-release-upstream
/etc/issue
/etc/issue.net
/etc/os-release
/etc/pki/rpm-gpg
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Testing-7
/etc/redhat-release
/etc/rpm/macros.dist
/etc/system-release
/etc/system-release-cpe
/etc/yum.repos.d/CentOS-Base.repo
/etc/yum.repos.d/CentOS-CR.repo
/etc/yum.repos.d/CentOS-Debuginfo.repo
/etc/yum.repos.d/CentOS-Media.repo
/etc/yum.repos.d/CentOS-Sources.repo
/etc/yum.repos.d/CentOS-Vault.repo
/etc/yum.repos.d/CentOS-fasttrack.repo
/etc/yum.repos.d/CentOS-x86_64-kernel.repo
/etc/yum/vars/contentdir
/etc/yum/vars/infra
/usr/lib/os-release
/usr/lib/systemd/system-preset/85-display-manager.preset
/usr/lib/systemd/system-preset/90-default.preset
/usr/share/centos-release/EULA
/usr/share/doc/centos-release/Contributors
/usr/share/doc/centos-release/GPL
/usr/share/doc/redhat-release
/usr/share/redhat-release

バージョン確認するときはいつも何気なしに/etc/redhat-releaseをみてたけど、こういうことだったのね...

あとはhostnamectlもわりとまとめてみられる。

[root@host01 ~]# hostnamectl
   Static hostname: host01
         Icon name: computer-server
           Chassis: server
        Machine ID: 638128914a9249d0a03b20cadXXXXXXX
           Boot ID: d37024b5ce6c446b8b17cd626XXXXXXX
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-1160.el7.x86_64
      Architecture: x86-64
[root@host01 ~]#

いじょ。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1