Linux 硬件操作命令汇总

发布时间: 更新时间: 总字数:1109 阅读时间:3m 作者: 分享 复制网址
专栏文章
  1. Linux 硬件操作命令汇总(当前)
  2. GPU 相关命令使用

Linux 硬件操作命令汇总

硬件架构

  • 北桥(North Bridge、Host Bridge) 主要负责CPU和内存、显卡这些部件的数据传送
  • 南桥(South Bridge) 主要负责I/O设备、外部存储设备以及BIOS之间的通信

获取硬件信息

  • iostat
iostat -xm -o JSON /dev/sdb |grep disk_device
iostat -x 1 2 -o JSON /dev/sdb
  • dmidecode
$ dmidecode -t 1
# dmidecode 3.0
Getting SMBIOS data from sysfs.
SMBIOS 2.8 present.

Handle 0x0100, DMI type 1, 27 bytes
System Information
	Manufacturer: Alibaba Cloud
	Product Name: Alibaba Cloud ECS
	Version: pc-i440fx-2.1
	Serial Number: 702ebfc5-005d-493f-9146-441f447a2529
	UUID: 702EBFC5-005D-493F-9146-441F447A2529
	Wake-up Type: Power Switch
	SKU Number: Not Specified
	Family: Not Specified
  • lshw
lshw
$ yum install -y lshw
$ lshw
a1.xiexianbin.cn
    description: Computer
    product: Alibaba Cloud ECS
    vendor: Alibaba Cloud
    version: pc-i440fx-2.1
    serial: 702ebfc5-005d-493f-9146-441f447a2529
    width: 64 bits
    capabilities: smbios-2.8 dmi-2.8 vsyscall32
    configuration: boot=normal uuid=C5BF2E70-5D00-3F49-9146-441F447A2529
  *-core
       description: Motherboard
       physical id: 0
     *-firmware
          description: BIOS
          vendor: SeaBIOS
          physical id: 0
          version: 3288b3c
          date: 04/01/2014
          size: 96KiB
     *-cpu
          description: CPU
          product: Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz
          vendor: Intel Corp.
          vendor_id: GenuineIntel
          physical id: 400
          bus info: cpu@0
          version: 6.79.1
          slot: CPU 0
          width: 64 bits
          capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp x86-64 constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt spec_ctrl intel_stibp
          configuration: cores=1 enabledcores=1 microcode=0 threads=2
     *-memory
          description: System Memory
          physical id: 1000
          size: 2GiB
          capacity: 2GiB
          capabilities: ecc
          configuration: errordetection=multi-bit-ecc
        *-bank
             description: DIMM RAM
             vendor: Alibaba Cloud
             physical id: 0
             slot: DIMM 0
             size: 2GiB
     *-pci
          description: Host bridge
          product: 440FX - 82441FX PMC [Natoma]
          vendor: Intel Corporation
          physical id: 100
          bus info: pci@0000:00:00.0
          version: 02
          width: 32 bits
          clock: 33MHz
        *-isa
             description: ISA bridge
             product: 82371SB PIIX3 ISA [Natoma/Triton II]
             vendor: Intel Corporation
             physical id: 1
             bus info: pci@0000:00:01.0
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: isa
             configuration: latency=0
        *-ide
             description: IDE interface
             product: 82371SB PIIX3 IDE [Natoma/Triton II]
             vendor: Intel Corporation
             physical id: 1.1
             bus info: pci@0000:00:01.1
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: ide isa_compat_mode bus_master
             configuration: driver=ata_piix latency=0
             resources: irq:0 ioport:1f0(size=8) ioport:3f6 ioport:170(size=8) ioport:376 ioport:c0c0(size=16)
        *-usb
             description: USB controller
             product: 82371SB PIIX3 USB [Natoma/Triton II]
             vendor: Intel Corporation
             physical id: 1.2
             bus info: pci@0000:00:01.2
             version: 01
             width: 32 bits
             clock: 33MHz
             capabilities: uhci bus_master
             configuration: driver=uhci_hcd latency=0
             resources: irq:11 ioport:c040(size=32)
           *-usbhost
                product: UHCI Host Controller
                vendor: Linux 3.10.0-862.14.4.el7.x86_64 uhci_hcd
                physical id: 1
                bus info: usb@1
                logical name: usb1
                version: 3.10
                capabilities: usb-1.10
                configuration: driver=hub slots=2 speed=12Mbit/s
              *-usb
                   description: Mouse
                   product: QEMU USB Tablet
                   vendor: QEMU
                   physical id: 1
                   bus info: usb@1:1
                   version: 0.00
                   serial: 42
                   capabilities: usb-2.00
                   configuration: driver=usbhid maxpower=100mA speed=12Mbit/s
        *-bridge
             description: Bridge
             product: 82371AB/EB/MB PIIX4 ACPI
             vendor: Intel Corporation
             physical id: 1.3
             bus info: pci@0000:00:01.3
             version: 03
             width: 32 bits
             clock: 33MHz
             capabilities: bridge
             configuration: driver=piix4_smbus latency=0
             resources: irq:9
        *-display
             description: VGA compatible controller
             product: GD 5446
             vendor: Cirrus Logic
             physical id: 2
             bus info: pci@0000:00:02.0
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: vga_controller rom
             configuration: driver=cirrus latency=0
             resources: irq:0 memory:fc000000-fdffffff memory:febd0000-febd0fff memory:febc0000-febcffff
        *-network
             description: Ethernet controller
             product: Virtio network device
             vendor: Red Hat, Inc.
             physical id: 3
             bus info: pci@0000:00:03.0
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: msix bus_master cap_list rom
             configuration: driver=virtio-pci latency=0
             resources: irq:10 ioport:c060(size=32) memory:febd1000-febd1fff memory:feb80000-febbffff
           *-virtio0
                description: Ethernet interface
                physical id: 0
                bus info: virtio@0
                logical name: eth0
                serial: 00:16:3e:08:ec:f1
                capabilities: ethernet physical
                configuration: broadcast=yes driver=virtio_net driverversion=1.0.0 ip=172.31.8.211 link=yes multicast=yes
        *-communication
             description: Communication controller
             product: Virtio console
             vendor: Red Hat, Inc.
             physical id: 4
             bus info: pci@0000:00:04.0
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: msix bus_master cap_list
             configuration: driver=virtio-pci latency=0
             resources: irq:11 ioport:c080(size=32) memory:febd2000-febd2fff
           *-virtio1 UNCLAIMED
                description: Virtual I/O device
                physical id: 0
                bus info: virtio@1
                configuration: driver=virtio_console
        *-scsi
             description: SCSI storage controller
             product: Virtio block device
             vendor: Red Hat, Inc.
             physical id: 5
             bus info: pci@0000:00:05.0
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: scsi msix bus_master cap_list
             configuration: driver=virtio-pci latency=0
             resources: irq:10 ioport:c000(size=64) memory:febd3000-febd3fff
           *-virtio2
                description: Virtual I/O device
                physical id: 0
                bus info: virtio@2
                logical name: /dev/vda
                size: 40GiB (42GB)
                capabilities: partitioned partitioned:dos
                configuration: driver=virtio_blk logicalsectorsize=512 sectorsize=512 signature=0008d73a
              *-volume
                   description: EXT4 volume
                   vendor: Linux
                   physical id: 1
                   bus info: virtio@2,1
                   logical name: /dev/vda1
                   logical name: /
                   logical name: /var/lib/docker/containers
                   logical name: /var/lib/docker/overlay2
                   version: 1.0
                   serial: eb448abb-3012-4d8d-bcde-94434d586a31
                   size: 39GiB
                   capacity: 39GiB
                   capabilities: primary bootable journaled extended_attributes large_files huge_files dir_nlink recover extents ext4 ext2 initialized
                   configuration: created=2017-10-15 23:18:59 filesystem=ext4 lastmountpoint=/ modified=2019-06-26 23:34:59 mount.fstype=ext4 mount.options=rw,relatime,data=ordered mounted=2019-06-26 15:35:03 state=mounted
        *-generic
             description: Unclassified device
             product: Virtio memory balloon
             vendor: Red Hat, Inc.
             physical id: 6
             bus info: pci@0000:00:06.0
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: bus_master
             configuration: driver=virtio-pci latency=0
             resources: irq:11 ioport:c0a0(size=32)
           *-virtio3 UNCLAIMED
                description: Virtual I/O device
                physical id: 0
                bus info: virtio@3
                configuration: driver=virtio_balloon
     *-pnp00:00
          product: PnP device PNP0b00
          physical id: 1
          capabilities: pnp
          configuration: driver=rtc_cmos
     *-pnp00:01
          product: PnP device PNP0303
          physical id: 2
          capabilities: pnp
          configuration: driver=i8042 kbd
     *-pnp00:02
          product: PnP device PNP0f13
          physical id: 3
          capabilities: pnp
          configuration: driver=i8042 aux
     *-pnp00:03
          product: PnP device PNP0700
          physical id: 4
          capabilities: pnp
     *-pnp00:04
          product: PnP device PNP0501
          physical id: 5
          capabilities: pnp
          configuration: driver=serial
  *-network:0
       description: Ethernet interface
       physical id: 1
       logical name: vethfe4b025
       serial: f2:27:43:49:86:e7
       size: 10Gbit/s
       capabilities: ethernet physical
       configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full link=yes multicast=yes port=twisted pair speed=10Gbit/s
  *-network:1
       description: Ethernet interface
       physical id: 2
       logical name: docker0
       serial: 02:42:20:2b:43:9d
       capabilities: ethernet physical
       configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=172.17.0.1 link=yes multicast=yes

Disk

  • 磁盘详情
apt install -y smartmontools
smartctl -i /dev/sdi
smartctl --json -i /dev/sdi
  • 容量
df -B1
df -B1GiB
df -B1GB
  • 区分是机械盘还是SSD/VNME

根据是否可以转判断。如上是机械盘为 1,否则为 0

$ cat /sys/block/sdi/queue/rotational
  • 分区
$ blkid /dev/vda1
/dev/vda1: UUID="eb448abb-3012-4d8d-bcde-94434d586a31" TYPE="ext4"
  • VNME 设备

NVME(Non-Volatile Memory Express)

$ apt install -y nvme-cli
$ nvme list

$ fdisk -l  | grep nvme
Disk /dev/nvme0n1: 3.65 TiB, 4000787030016 bytes, 7814037168 sectors
专栏文章
  1. Linux 硬件操作命令汇总(当前)
  2. GPU 相关命令使用
最新评论
加载中...
Home Archives Categories Tags Statistics