如何查看Linux VPS的虛擬化類型?

如何查看Linux VPS的虛擬化類型?

訪問 VPS 後,我需要知道它正在從終端運行哪種類型的虛擬化。

如何確定我的虛擬機器運作的虛擬化平台? (OpenVZ、Xen、KVM 等?)

答案1

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

開放VZ

$ 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

鍵盤虛擬機

$ 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

答案2

除非虛擬機器主機對您撒謊,否則通常可以透過檢查虛擬機器來賓所看到的「硬體」來弄清楚。

最簡單的可能是使用類似的程序虛擬什麼,它將為您進行解析。順便說一下,我在這裡盲目地假設您正在運行某種基於 Linux 的發行版。

也許還值得一看木偶的因素,它也使用類似的技術來確定它在哪種虛擬機器環境中運作。

或者你可以問你從誰那裡租用 VPS 嗎? :-)

答案3

使用該virt-what命令確定係統正在使用的虛擬化技術的類型。

看:http://people.redhat.com/~rjones/virt-what/

答案4

Debian 附帶了這個小軟體包來檢測虛擬化類型:

$ sudo apt-get install virt-what
$ virt-what

由於 Perl 依賴性,尺寸更大一些:

$ sudo apt-get install imvirt
$ imvirt

相關內容