1.使用dmidecode命令查看(root权限)
dmidecode -s system-product-name VMware Virtual Platform //包含virtual字样,为虚拟机 dmidecode -s system-product-name PowerEdge R730 //不包含virtual字样,为物理机
2.使用dmesg命令查看(root权限)
dmesg|grep -i dmi: DMI: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 04/14/2014 //包含virtual字样,为虚拟机 dmesg|grep -i dmi: [ 0.000000] DMI: Dell Inc. PowerEdge R730/04N3DF, BIOS 2.5.5 [OEM 1.0.0] 09/27/2017 //不包含virtual字样,为物理机
参考文档: