如何判断虚拟机采用哪种虚拟化技术

发布时间: 更新时间: 总字数:305 阅读时间:1m 作者: IP上海 分享 网址

如何判断 Linux VM 采用哪种虚拟化技术

virt-what

安装

Ubuntu

apt install virt-what

CentOS

yum install virt-what

使用

$ virt-what
kvm

输出:

  • aws : Amazon Web Services
  • docker : This is a Docker container.
  • hyperv : This is Microsoft Hyper-V hypervisor.
  • lxc : This process is running in a Linux LXC container.
  • kvm : This guest is running on the KVM hypervisor using hardware acceleration.
  • openvz : The guest appears to be running inside an OpenVZ or Virtuozzo container.
  • parallels : The guest is running inside Parallels Virtual Platform (Parallels Desktop, Parallels Server).
  • qemu : This is QEMU hypervisor using software emulation.
  • virt : Some sort of virtualization appears to be present, but we are not sure what it is.
  • virtualbox : This is a VirtualBox guest.
  • vmware : The guest appears to be running on VMware hypervisor.
  • xen The guest appears to be running on Xen hypervisor.
  • xen-hvm : This is a Xen guest fully virtualized (HVM).

更多内容见:man virt-what

dmidecode

$ dmidecode -s system-manufacturer
VMware, Inc.
$ dmidecode -s system-product-name
VMware7,1

systemd-detect-virt

# apt install systemd -y
$ systemd-detect-virt
vmware

docker

  • 根目录会生产 /.dockerenv 文件
  • 通过 /proc/1/cgroup/proc/1/cpuset 检查是否有 docker 字段
$ cat /proc/1/cgroup | grep docker
13:blkio:/docker/582fd9275fbffd1b9f2c716eead28da399f54c7792b38d74fd82d5eb6bc3421f
11:devices:/docker/582fd9275fbffd1b9f2c716eead28da399f54c7792b38d74fd82d5eb6bc3421f
10:cpu,cpuacct:/docker/582fd9275fbffd1b9f2c716eead28da399f54c7792b38d74fd82d5eb6bc3421f
9:hugetlb:/docker/582fd9275fbffd1b9f2c716eead28da399f54c7792b38d74fd82d5eb6bc3421f
8:memory:/docker/582fd9275fbffd1b9f2c716eead28da399f54c7792b38d74fd82d5eb6bc3421f
7:perf_event:/docker/582fd9275fbffd1b9f2c716eead28da399f54c7792b38d74fd82d5eb6bc3421f
5:cpuset:/docker/582fd9275fbffd1b9f2c716eead28da399f54c7792b38d74fd82d5eb6bc3421f
4:freezer:/docker/582fd9275fbffd1b9f2c716eead28da399f54c7792b38d74fd82d5eb6bc3421f
3:net_cls,net_prio:/docker/582fd9275fbffd1b9f2c716eead28da399f54c7792b38d74fd82d5eb6bc3421f
2:pids:/docker/582fd9275fbffd1b9f2c716eead28da399f54c7792b38d74fd82d5eb6bc3421f
1:name=systemd:/docker/582fd9275fbffd1b9f2c716eead28da399f54c7792b38d74fd82d5eb6bc3421f
$ cat /proc/1/cpuset
/docker/582fd9275fbffd1b9f2c716eead28da399f54c7792b38d74fd82d5eb6bc3421f
  • /proc/1/sched 中若不是 systemd 也可能是 docker 容器
$ cat /proc/1/sched
bash (1, #threads: 1)
...

k8s pod

k8s 启动的容器,init 进程 一般为 /pause,如下图

$ ps -ef
PID   USER     TIME  COMMAND
    1 root      0:00 /pause

参考

  1. https://people.redhat.com/~rjones/virt-what/
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数