如何判断当前系统运行在物理机上还是虚拟机上,返回虚拟机的类型
Posted navysummer
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何判断当前系统运行在物理机上还是虚拟机上,返回虚拟机的类型相关的知识,希望对你有一定的参考价值。
virt-what
一般系统都会自带virt-what,若程序没带的话 自己下载安装即可
[[email protected] ~]# yum install virt-what [[email protected] ~]# virt-what vmware
用lspci -b|grep "VMware"抓取系列信息,即表明此系统的宿主机是基于VMware虚拟出来的,别的可以
[[email protected] ~]# 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 均有以下字样
[[email protected] ~]# 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
[[email protected] ~]# 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
Windows:
在CMD里输入:Systeminfo | findstr /i "System Model" 如果System Model:后面含有Virutal就是虚拟机,其他都是物理机 或者用powershell命令:get-wmiobject win32_computersystem | fl model
Linux:
在bash里输入:dmidecode -s system-product-name 或者lshw -class system 或者dmesg | grep -i virtual
以上是关于如何判断当前系统运行在物理机上还是虚拟机上,返回虚拟机的类型的主要内容,如果未能解决你的问题,请参考以下文章