判断服务器是虚拟机还是物理机方式
一、如果是Windows:
1、cmd使用命令:systeminfo | findstr /i "System Model"
如果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)
2、或者用powershell命令:get-wmiobject win32_computersystem | fl model
二、如果是Linux:
1、在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
input: Macintosh mouse button emulation as /devices/virtual/input/input2