在银河麒麟服务器操作系统(Kylin OS,通常基于 Linux,如 Ubuntu 或 CentOS 衍生版)上,如果你拥有 root 或 sudo 权限(例如在物理机或具有完整权限的虚拟机/VPS 中),可以通过以下命令查询物理服务器的硬件信息(包括型号、序列号、制造商等,常被称作“物理服务器信息”或“资产信息”)。
注意
如果你运行在云服务器或受限虚拟机中,部分底层硬件信息可能被虚拟化层屏蔽。
以下操作需在终端中执行,并确保已安装必要工具。
方法一:使用 dmidecode(最常用,可查 BIOS/主板/系统信息)
[root@localhost ~]# dmidecode -t system
# dmidecode 3.4
Getting SMBIOS data from sysfs.
SMBIOS 3.6 present.
# SMBIOS implementations newer than version 3.5.0 are not
# fully supported by this version of dmidecode.
Handle 0x0059, DMI type 1, 27 bytes
System Information
Manufacturer: ZTE
Product Name: R6930 G3
Version: NULL
Serial Number: 219613425327
UUID: 674a0198-0000-1000-0000-30b9303d2ff9
Wake-up Type: AC Power Restored
SKU Number: N/A
Family: Server
Handle 0x006A, DMI type 32, 11 bytes
System Boot Information
Status: No errors detected
关键字段:
Manufacturer:厂商(如 Huawei、Inspur、Lenovo、Dell)
Product Name:服务器型号(如 RH2288H V3、TaiShan 2280)
Serial Number:序列号(用于资产追踪)
方法二:查看 /sys/class/dmi/id/(无需额外工具)
[root@localhost ~]# cat /sys/class/dmi/id/product_name
R6930 G3
[root@localhost ~]# cat /sys/class/dmi/id/sys_vendor
ZTE
[root@localhost ~]# cat /sys/class/dmi/id/product_serial
219613425327
方法三:使用 lshw(列出详细硬件层次结构)
[root@localhost ~]# lshw -class system
localhost.localdomain
description: Rack Mount Chassis
product: R6930 G3 (N/A)
vendor: ZTE
version: NULL
serial: 219613425327
width: 64 bits
capabilities: smbios-3.6.0 dmi-3.6.0 smp vsyscall32
configuration: administrator_password=disabled boot=normal chassis=rackmount family=Server frontpanel_password=enabled power-on_password=disabled sku=N/A uuid=98014A67-0000-0010-0000-30B9303D2FF9
*-pnp00:00
product: PnP device PNP0c02
physical id: 0
capabilities: pnp
configuration: driver=system
*-pnp00:01
product: PnP device PNP0b00
physical id: 1
capabilities: pnp
configuration: driver=rtc_cmos
*-pnp00:02
product: PnP device PNP0c02
physical id: 2
capabilities: pnp
configuration: driver=system
*-pnp00:03
product: PnP device PNP0c01
physical id: 3
capabilities: pnp
configuration: driver=system
方法四:查看 CPU 和内存信息(辅助判断服务器平台)
[root@localhost ~]# lscpu
架构: x86_64
CPU 运行模式: 32-bit, 64-bit
字节序: Little Endian
Address sizes: 48 bits physical, 48 bits virtual
CPU: 256
在线 CPU 列表: 0-255
每个核的线程数: 2
每个座的核数: 64
座: 2
NUMA 节点: 8
厂商 ID: HygonGenuine
BIOS Vendor ID: Chengdu Hygon
CPU 系列: 24
型号: 4
型号名称: Hygon C86-4G (OPN:7490)
BIOS Model name: Hygon C86-4G (OPN:7490)
步进: 1
CPU MHz: 2699.762
BogoMIPS: 5399.52
虚拟化: AMD-V
L1d 缓存: 4 MiB
L1i 缓存: 4 MiB
L2 缓存: 64 MiB
L3 缓存: 512 MiB
NUMA 节点0 CPU: 0-15,128-143
NUMA 节点1 CPU: 16-31,144-159
NUMA 节点2 CPU: 32-47,160-175
NUMA 节点3 CPU: 48-63,176-191
NUMA 节点4 CPU: 64-79,192-207
NUMA 节点5 CPU: 80-95,208-223
NUMA 节点6 CPU: 96-111,224-239
NUMA 节点7 CPU: 112-127,240-255
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Retbleed: Mitigation; untrained return thunk; SMT enabled with STIBP protection
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP always-on, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
标记: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr
_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid amd_dcm aperfmperf pni pclmulqdq monitor ss
se3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4
a misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb hw_pstate sme
ssbd csv ibrs ibpb stibp vmmcall csv2 csv3 fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec x
getbv1 xsaves clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists paus
efilter pfthreshold avic v_vmsave_vmload vgif umip overflow_recov succor smca sm3 sm4
[root@localhost ~]# lshw -short -C memory
H/W path Device Class Description
===========================================================
/0/58 memory 64KiB BIOS
/0/b/8 memory 4MiB L1 cache
/0/b/9 memory 32MiB L2 cache
/0/b/a memory 256MiB L3 cache
/0/f/c memory 4MiB L1 cache
/0/f/d memory 32MiB L2 cache
/0/f/e memory 256MiB L3 cache
/0/5 memory 2304GiB System Memory
/0/5/0 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/1 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/2 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/3 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/4 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/5 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/6 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/7 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/8 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/9 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/a memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/b memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/c memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/d memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/e memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/f memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/10 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/11 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/12 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/13 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/14 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/15 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/16 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
/0/5/17 memory 96GiB DIMM Synchronous Registered (Buffered) 5600 MHz (0.2 ns)
[root@localhost ~]# cat /proc/meminfo
MemTotal: 2372319804 kB
MemFree: 2349955888 kB
MemAvailable: 2345152560 kB
Buffers: 4028 kB
Cached: 2478348 kB
SwapCached: 0 kB
Active: 5588088 kB
Inactive: 1420476 kB
Active(anon): 4541352 kB
Inactive(anon): 172576 kB
Active(file): 1046736 kB
Inactive(file): 1247900 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 4194300 kB
SwapFree: 4194300 kB
Dirty: 16 kB
Writeback: 0 kB
AnonPages: 4497020 kB
Mapped: 780668 kB
Shmem: 187740 kB
KReclaimable: 363536 kB
Slab: 1237148 kB
SReclaimable: 363536 kB
SUnreclaim: 873612 kB
KernelStack: 51936 kB
PageTables: 26320 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1190354200 kB
Committed_AS: 13998568 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
Percpu: 10697728 kB
HardwareCorrupted: 0 kB
AnonHugePages: 4001792 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB
DirectMap4k: 759288 kB
DirectMap2M: 27305984 kB
DirectMap1G: 2384461824 kB
如何判断是物理机还是虚拟机
[root@localhost ~]# systemd-detect-virt
none
返回 none → 物理机
返回 kvm, xen, vmware 等 → 虚拟机
还可以通过如下命令如果返回OpenStack Foundation就是虚拟机
[root@test ~]# dmidecode -t system | grep -E "Manufacturer|Product Name|Serial Number"
Manufacturer: OpenStack Foundation
Product Name: OpenStack Nova
Serial Number: 0918dbd3-6e47-4e75-9b57-65259c412a79
[root@test ~]#
[root@test ~]# cat /sys/class/dmi/id/{sys_vendor,product_name,product_serial}
OpenStack Foundation
OpenStack Nova
0918dbd3-6e47-4e75-9b57-65259c412a79
3553

被折叠的 条评论
为什么被折叠?



