[Windows/Linux]判别当前主机: 虚拟机 | 物理机

Windows

CMD(Ctrl+R): systeminfo
[Windows/Linux]判别当前主机: 虚拟机 | 物理机

Linux

dmesg |grep -i virtual

(以CentOS为例)

  • 公司服务器(虚拟机)
[root@xx92 ~]# dmesg |grep -i virtual
DMI: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 09/30/2014
Booting paravirtualized kernel on bare hardware
input: Macintosh mouse button emulation as /devices/virtual/input/input1
ata2.00: ATAPI: VMware Virtual IDE CDROM Drive, 00000001, max UDMA/33
scsi 2:0:0:0: Direct-Access     VMware   Virtual disk     1.0  PQ: 0 ANSI: 2
scsi 2:0:1:0: Direct-Access     VMware   Virtual disk     1.0  PQ: 0 ANSI: 2
scsi 2:0:2:0: Direct-Access     VMware   Virtual disk     1.0  PQ: 0 ANSI: 2
VMware vmxnet3 virtual NIC driver - version 1.4.2.0-k-NAPI

[root@xx117-rac2 ~]# dmesg |grep -i virtual
DMI: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 09/30/2014
Booting paravirtualized kernel on bare hardware
input: Macintosh mouse button emulation as /devices/virtual/input/input1
ata2.00: ATAPI: VMware Virtual IDE CDROM Drive, 00000001, max UDMA/33
scsi 2:0:0:0: Direct-Access     VMware   Virtual disk     1.0  PQ: 0 ANSI: 2
VMware vmxnet3 virtual NIC driver - version 1.4.2.0-k-NAPI
  • 个人阿里云主机(虚拟机)
[root@xxx ~]# dmesg |grep -i virtual
[    0.000000] Booting paravirtualized kernel on KVM
[    0.358209] KVM setup paravirtual spinlock
[    1.078791] input: 【VirtualPS/2 VMware VMMouse】 as /devices/platform/i8042/serio1/input/input2
[    1.084293] input: VirtualPS/2 VMware VMMouse as /devices/platform/i8042/serio1/input/input3
[    1.135730] systemd[1]: Detected virtualization kvm.
[    1.196870] systemd[1]: Starting Setup Virtual Console...
  • 物理机
[root@xxx]# dmesg |grep -i virtual
Booting paravirtualized kernel on bare hardware
input: Macintosh mouse button emulation as /devices/virtual/input/input1

lscpu

  • 虚拟机
[root@es1 elasticsearch]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                8
On-line CPU(s) list:   0-7
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             8
NUMA node(s):          1
Vendor ID:             GenuineIntel //(Vendor: 供应商)
...
Model name:            Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz
...
Hypervisor vendor:     VMware //【判断点】
Virtualization type:   full
...
[root@sdc92 ~]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
...
Vendor ID:             GenuineIntel 
...
Model name:            Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz
...
Hypervisor vendor:     VMware //判断点 (Hypervisor vendor: 虚拟机监控程序 供应商)
Virtualization type:   full
...

(↓个人阿里云虚拟机)

[root@iz2vc84t88x94kno0u49zwz ~]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                1
On-line CPU(s) list:   0
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel

Model name:            Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz
Stepping:              4
CPU MHz:               2500.016
BogoMIPS:              5000.03
Hypervisor vendor:     KVM //判断点, KVM = Keyboard Video Mouse
Virtualization type:   full
...

dmidecode -s system-product-name

  • 个人阿里云虚拟机
[root@iz2vc84t88x94kno0u49zwz ~]# dmidecode -s system-product-name
Alibaba Cloud ECS

X 文献

[Windows/Linux]判别当前主机: 虚拟机 | 物理机

上一篇:转:[Asp.net]常见数据导入Excel,Excel数据导入数据库解决方案,总有一款适合你!


下一篇:C# 在SQLite数据库中存储图像 z