判斷服務器是虛擬機還是物理機方式

一、如果是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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章