Linux查看是虚拟机还是物理机

第一种方式:dmesg命令

bash 复制代码
[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

第二种方式:lscpu命令

如果lscpu命令输出中出现Hypervisor vendor: KVM则表示是虚拟机,而出现Virtualization: VT-x则表示是实体机。

bash 复制代码
[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

虚拟化技术有两种类型的实现:

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

第三种方式:systemd-detect-virt命令

bash 复制代码
[root@test ~]# systemd-detect-virt
vmware

第四种方式:dmidecode命令

bash 复制代码
[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

常见的云主机输出结果

相关推荐
weixin_3077791314 小时前
在 Microsoft Azure 上部署 ClickHouse 数据仓库:托管服务与自行部署的全面指南
开发语言·数据库·数据仓库·云计算·azure
xiaogg367818 小时前
阿里云k8s部署微服务yaml和Dockerfile文件脚本
阿里云·微服务·kubernetes
weixin_3077791318 小时前
AWS Redshift 数据仓库完整配置与自动化管理指南
开发语言·数据仓库·python·云计算·aws
AKAMAI1 天前
直播监控的生死时速:深夜告警引发的系统崩溃危机
人工智能·云计算·直播
TG_yunshuguoji1 天前
阿里云代理商:什么是阿里云CDN配额?
阿里云·云计算
小张课程1 天前
系统入门云计算服务,项目上云综合实践
云计算
Adorable老犀牛2 天前
阿里云-ECS实例信息统计并发送统计报告到企业微信
python·阿里云·云计算·企业微信
wanhengidc2 天前
云手机长期使用会消耗很多流量吗
网络·游戏·智能手机·架构·云计算
SaaS_Product2 天前
有安全好用且稳定的共享网盘吗?
人工智能·云计算·saas·onedrive
数据与人工智能律师2 天前
解码Web3:DeFi、GameFi、SocialFi的法律风险警示与合规路径
大数据·网络·人工智能·云计算·区块链