如何判斷當前系統運行在物理機上仍是虛擬機上,返回虛擬機的類型

virt-what

通常系統都會自帶virt-what,若程序沒帶的話 本身下載安裝便可shell

[root@localhost ~]# yum install virt-what

[root@localhost ~]# virt-what
vmware

 用lspci -b|grep "VMware"抓取系列信息,即代表此係統的宿主機是基於VMware虛擬出來的,別的能夠

[root@localhost ~]# lspci -b|grep "VMware"
00:07.7 System peripheral: VMware Virtual Machine Communication Interface (rev 10)
00:0f.0 VGA compatible controller: VMware SVGA II Adapter
00:11.0 PCI bridge: VMware PCI bridge (rev 02)
00:15.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.2 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.3 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.4 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.5 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.6 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.7 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.2 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.3 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.4 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.5 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.6 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.7 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.2 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.3 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.4 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.5 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.6 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.7 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.2 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.3 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.4 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.5 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.6 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.7 PCI bridge: VMware PCI Express Root Port (rev 01)
02:00.0 USB controller: VMware USB1.1 UHCI Controller
02:03.0 USB controller: VMware USB2 EHCI Controller

還能夠用 dmesg 和 dmidecode  均有如下字樣bash

[root@localhost ~]# dmesg | grep VMware
[    0.000000] DMI: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 04/13/2018
[    0.000000] Hypervisor detected: VMware
[    0.000000] Booting paravirtualized kernel on VMware hypervisor
[    2.486307] input: VirtualPS/2 VMware VMMouse as /devices/platform/i8042/serio1/input/input2
[    2.488088] input: VirtualPS/2 VMware VMMouse as /devices/platform/i8042/serio1/input/input3
[    2.900512] usb 2-1: Product: VMware Virtual USB Mouse
[    2.900516] usb 2-1: Manufacturer: VMware
[    2.911424] input: VMware VMware Virtual USB Mouse as /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-1/2-1:1.0/input/input4
[    2.911718] hid-generic 0003:0E0F:0003.0001: input,hidraw0: USB HID v1.10 Mouse [VMware VMware Virtual USB Mouse] on usb-0000:02:00.0-1/input0
[    3.163066] usb 2-2: Product: VMware Virtual USB Hub
[    8.059298] scsi 0:0:0:0: Direct-Access     VMware,  VMware Virtual S 1.0  PQ: 0 ANSI: 2
[    8.278897] ata2.00: ATAPI: VMware Virtual IDE CDROM Drive, 00000001, max UDMA/33
[    8.299589] scsi 2:0:0:0: CD-ROM            NECVMWar VMware IDE CDR10 1.00 PQ: 0 ANSI: 5
[root@localhost ~]# dmidecode | grep VMware
    Manufacturer: VMware, Inc.
    Product Name: VMware Virtual Platform
    Serial Number: VMware-56 4d c4 fe d0 45 68 cc-5e e3 70 9c 38 e8 a2 3f
    Description: VMware SVGA II

facter ide

$facter virtual

physical

$facter virtual 
vmware

 cat /proc/scsi/scsispa

 

 Windows:code

在CMD裏輸入:Systeminfo | findstr /i "System Model"
若是System Model:後面含有Virutal就是虛擬機,其餘都是物理機
或者用powershell命令:get-wmiobject win32_computersystem | fl model

Linux:orm

在bash裏輸入:dmidecode -s system-product-name
或者lshw -class system
或者dmesg | grep -i virtual
相關文章
相關標籤/搜索