作者:雨舒紫_586 | 来源:互联网 | 2024-10-24 08:14
在Linux系统中,可以通过执行特定命令来判断服务器是物理机还是虚拟机。例如,在CentOS系统中,运行`dmidecode|grep-A16"SystemInformation"`命令,查看输出中的“Manufacturer”和“ProductName”字段,这些信息可以帮助用户准确区分服务器的类型。此外,还可以通过检查`/sys/devices/virtual/dmi/id`目录下的文件内容,进一步确认服务器的具体型号和制造商信息。
centos:
物理机:
[root@db01 ~]# dmidecode |grep -A16 "System Information$"
System Information
Manufacturer: LENOVO
Product Name: Lenovo System x3850 X6
Version: 09
Serial Number: J3xxxx
UUID:
0xxB2E85-26xx-E711-A390-02E0EC431C8A
Wake-up Type: Reserved
SKU Number: none
Family: System X
Handle 0x0074, DMI type 2, 17 bytes
Base Board Information
Manufacturer: LENOVO
Product Name: 00YA700
Version: E63448-400
Serial Number: xxxxxx
Asset Tag: Base Board Asset Tag
[root@db01 ~]#
xen 虚拟机:
[root@dg ~]# dmidecode |grep -A16 "System Information$"
System Information
Manufacturer: Xen
Product Name: HVM domU
Version: 4.7.1-1.9
Serial Number:
9d12fe08-88d0-dab5-21ac-b4294e79ccf1
UUID:
9D12FE08-87D0-DAB5-31AC-B4294E79CCF1
Wake-up Type: Power Switch
SKU Number: Not Specified
Family: Not Specified
Handle 0x0300, DMI type 3, 13 bytes
Chassis Information
Manufacturer: Xen
Type: Other
Lock: Not Present
Version: Not Specified
Serial Number: Not Specified
[root@dg ~]#
VMWARE虚拟机:
[root@dbserver ~]# dmidecode |grep -A16 "System Information$"
System Information
Manufacturer: VMware, Inc.
Product Name: VMware Virtual Platform
Version: None
Serial Number: VMware-56 4d 53 25 bb 20 6c be-83 27 e2 c2 31 c3 02 1f
UUID:
25534d56-20bb-be6c-8327-e2c231c3021f
Wake-up Type: Power Switch
SKU Number: Not Specified
Family: Not Specified
Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
Manufacturer: Intel Corporation
Product Name: 440BX Desktop Reference Platform
Version: None
Serial Number: None
Asset Tag: Not Specified
[root@dbserver ~]#
麒麟:
VMWARE虚拟机:
zhengquan@
zhengquan-vmwarevirtualplatform:~/桌面$ sudo dmidecode |grep -i "system information" -A16
System Information
Manufacturer: VMware, Inc.
Product Name: VMware Virtual Platform
Version: None
Serial Number: VMware-56 4d fe 83 cb a6 6e 6c-f5 cb 1d ba 10 46 74 37
UUID:
83fe4d56-a6cb-6c6e-f5cb-1dba10467437
Wake-up Type: Power Switch
SKU Number: Not Specified
Family: Not Specified
Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
Manufacturer: Intel Corporation
Product Name: 440BX Desktop Reference Platform
Version: None
Serial Number: None
Asset Tag: Not Specified