Check whether Linux is a virtual machine or a physical machine

The first way: dmesg command

[root@test ~]# dmesg | grep -i hypervisor
[    0.000000] Hypervisor detected: VMware
[    0.001000] TSC freq read from hypervisor : 2903.999 MHz
[    6.311621] [drm] Max dedicated hypervisor surface memory is 0 kiB

Second way: lscpu command

If lscpuit appears in the command output Hypervisor vendor: KVM, it means it is a virtual machine, and if it appears Virtualization: VT-x, it means it is a physical machine.

[root@test ~]# lscpu | grep Hypervisor
[root@test ~]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    1
Core(s) per socket:    2
座:                 2
NUMA 节点:         1
厂商 ID:           GenuineIntel
CPU 系列:          6
型号:              165
型号名称:        Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz
步进:              5
CPU MHz:             2903.999
BogoMIPS:            5807.99
超管理器厂商:  VMware
虚拟化类型:     完全
L1d 缓存:          32K
L1i 缓存:          32K
L2 缓存:           256K
L3 缓存:           16384K
NUMA 节点0 CPU:    0-3

There are two types of implementations of virtualization technology:

  • Type-I : hypervisor -> VM
  • Type-II:host -> VM -> VMS

The third way: systemd-detect-virt command

[root@test ~]# systemd-detect-virt
vmware

The fourth way: dmidecode command

[root@test ~]# dmidecode -t 1
# dmidecode 2.12
SMBIOS 2.7 present.

Handle 0x0001, DMI type 1, 27 bytes
System Information
        Manufacturer: VMware, Inc.
        Product Name: VMware Virtual Platform
        Version: None
        Serial Number: VMware-56 4d 2a a5 0b e5 cb 1c-04 3e 84 3e da c3 3c 4c
        UUID: A52A4D56-E50B-1CCB-043E-843EDAC33C4C
        Wake-up Type: Power Switch
        SKU Number: Not Specified
        Family: Not Specified

Common cloud host output results

Physical machine output results

VMware virtual machine output results

Alibaba Cloud host output results

Tencent cloud host output results

Vultr cloud host output results

Guess you like

Origin blog.csdn.net/qq_32262243/article/details/132571117