有了VPS的访问权限,我需要知道从terminal运行的虚拟化types。
如何确定我的虚拟机正在运行的虚拟化平台? (OpenVZ,Xen,KVM等?)
hostnamectl
是你的朋友(需要systemd
)。
几个例子:
笔记本没有任何虚拟化
$ hostnamectl status Static hostname: earth.gangs.net Icon name: computer-laptop Chassis: laptop Machine ID: 18a0752e1ccbeef09da51ad17fab1f1b Boot ID: beefdc99969e4a4a8525ff842b383c62 Operating System: Ubuntu 16.04.2 LTS Kernel: Linux 4.4.0-66-generic Architecture: x86-64
Xen的
$ hostnamectl status Static hostname: pluto.gangs.net Icon name: computer-vm Chassis: vm Machine ID: beef39aebbf8ba220ed0438b54497609 Boot ID: beefc71e97ed48dbb436a470fe1920e1 Virtualization: xen Operating System: Ubuntu 16.04.2 LTS Kernel: Linux 3.13.0-37-generic Architecture: x86-64
OpenVZ的
$ hostnamectl status Static hostname: mars.gangs.net Icon name: computer-container Chassis: container Machine ID: 55296cb0566a4aaca10b8e3a4b28beef Boot ID: 1bb259b0eb064d9eb8a22d112211beef Virtualization: openvz Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 2.6.32-042stab120.16 Architecture: x86-64
KVM
$ hostnamectl status Static hostname: mercury.gangs.net Icon name: computer-vm Chassis: vm Machine ID: beeffefc50ae499881b024c25895ec86 Boot ID: beef9c7662a240b3b3b04cef3d1518f0 Virtualization: kvm Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-514.10.2.el7.x86_64 Architecture: x86-64
除非VM主机在说谎,否则通常可以通过检查VM guest虚拟机正在看到的“硬件”来解决。
最简单的方法是使用一个像virt-what这样的程序,它会为你parsing。 在这里,我盲目地认为你正在运行某种基于Linux的分发。
也可能值得一看puppet的因素 ,它也使用类似的技术来确定它运行在什么样的虚拟机环境。
或者你可以问问你碰巧从谁租用VPS? 🙂
使用virt-what
命令来确定系统正在使用的虚拟化技术的types。
见: http : //people.redhat.com/~rjones/virt-what/
您也可以使用dmidecode
这将显示您的系统硬件信息和其他。
Debian带有这个检测虚拟化types的小软件包:
$ sudo apt-get install virt-what $ virt-what
而且因为Perl的依赖性而变得更大一些:
$ sudo apt-get install imvirt $ imvirt