如何判断当前主机是物理机还是虚拟机?

Windows:

在CMD里输入:Systeminfo | findstr /i "System Model"

如果System Model:后面含有Virutal就是虚拟机,其他都是物理机

如果System Model返回信息内:后面含有Virutal就是虚拟机,其他都是物理机

物理机输出:

C:\Users\Administrator>systeminfo |findstr /i "System Module"

System Boot Time:          8/20/2018, 06:30:23

System Manufacturer:       LENOVO

System Model:              90DSCTO1WW

System Type:               x64-based PC

System Directory:          C:\Windows\system32

System Locale:             zh-cn;Chinese (China)

或者用powershell命令:get-wmiobject win32_computersystem | fl model

Linux:

在bash里输入:dmidecode -s system-product-name

或者lshw -class system

或者dmesg | grep -i virtual

如果结果返回包含virtual,则是虚拟机:

[youedata@localhost ~]$ dmesg |grep -i virtual

[    0.000000] Booting paravirtualized kernel on Xen HVM

[    1.034572] systemd[1]: Detected virtualization xen.

[    1.065757] systemd[1]: Starting Setup Virtual Console...

[    1.287144] xen_netfront: Initialising Xen virtual ethernet driver

如果返回如下,基于hardware,则说明是物理机:

[youedata@localhost ~]$ dmesg|grep -i virtual

Booting paravirtualized kernel on bare hardware

具体参考:http://unix.stackexchange.com/questions/89714/easy-way-to-determine-virtualization-technology

posted @ 2019-03-13 22:40  konglingbin  阅读(6956)  评论(0编辑  收藏  举报