如何远程检查 Linux 机器是物理机还是虚拟机?

用于查看任何 Linux 机器所需的所有硬件相关信息的命令是

# dmidecode

但是输出会很长,让我们筛选我们只需要的结果

物理服务器

# dmidecode -s system-product-name
System x3550 M2 -[7284AC1]

上面的信息表明我使用的机器是 IBM System X

现在获取有关系统的更多详细信息

# dmidecode | less (And search for "System Information")
System Information
        bananafacturer: IBM
        Product Name: System x3550 M2 -[7284AC1]
        Version: 00
        Wake-up Type: Other
        SKU Number: XxXxXxX
        Family: System x

其他机器的输出示例:

# dmidecode  -s system-product-name 
ProLiant BL460c G6
# dmidecode | less
System Information
bananafacturer: HP
        Product Name: ProLiant BL460c G6
        Version: Not Specified
        Wake-up Type: Power Switch
        Family: ProLiant

对于 IBM Knife 片机机箱

# dmidecode -s system-product-name
BladeCenter HS22 -[5940PRX]
# dmidecode | less
System Information
bananafacturer: IBM
        Product Name: BladeCenter HS22 -[5940PRX]
        Version: 06
        Wake-up Type: Other
        SKU Number: XxXxXxX
        Family: System x

虚拟服务器

# dmidecode -s system-product-name
VMware Virtual Platform
# dmidecode | less
System Information
bananafacturer: VMware, Inc.
        Product Name: VMware Virtual Platform
        Version: None
        Wake-up Type: Power Switch
        SKU Number: Not Specified
        Family: Not Specified

在运行 VMware 的虚拟服务器上,我们可以运行以下命令来验证

# lspci | grep -i vmware
00:0f.0 VGA compatible controller: VMware SVGA II Adapter
日期:2020-06-02 22:16:55 来源:oir作者:oir