检查 VT-x 是否已激活而无需在 Linux 中重新启动?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11116704/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
check if VT-x is activated without having to reboot in Linux?
提问by 719016
I have a laptop with Intel Core i5 M 450 @ 2.40GHz which apparently has VT-x but not VT-d. I have Ubuntu 12.04 32bit but would like to have a virtual 64bit terminal-based Linux running on it. How do I know if the BIOS has this VT-x feature activated without having to reboot?
我有一台配备 Intel Core i5 M 450 @ 2.40GHz 的笔记本电脑,它显然有 VT-x 但没有 VT-d。我有 Ubuntu 12.04 32 位,但希望在其上运行基于 64 位终端的虚拟 Linux。我如何知道 BIOS 是否激活了此 VT-x 功能而无需重新启动?
采纳答案by scai
You can use rdmsrfrom msr-toolsto read register IA32_FEATURE_CONTROL(address 0x3a). The kernel module msrhas to be loaded for this.
您可以使用RDMSR从MSR工具读取寄存器IA32_FEATURE_CONTROL(地址0x3a)。为此必须加载内核模块msr。
On most Linux systems:
在大多数 Linux 系统上:
sudo modprobe msr
sudo rdmsr 0x3a
Values 3
and 5
mean it's activated.
值3
并5
表示它已激活。
回答by Gigamegs
In linux you can check cpuinfo:
在linux中你可以查看cpuinfo:
cat /proc/cpuinfo| egrep "vmx|svm"
回答by Tobu
You can use
您可以使用
sudo kvm-ok
from cpu-checker. On Intel, which has the most complicated logic, kvm-ok checksthat if bit 0 of rdmsr 0x3a
(the lock bit) is set, bit 2 (which allows virt use outside of SMX mode, something to do with trusted boot) must also be set. If the output of rdmsr 0x3a
is anything but 1or 3, you will be able to use kvm. kvm will set bit 2 of the msr if necessary, I expect virtualbox and the rest have the same logic.
来自cpu-checker。在逻辑最复杂的 Intel 上,kvm-ok检查是否rdmsr 0x3a
设置了(锁定位)的第0位,还必须设置第 2 位(允许在 SMX 模式之外使用 virt,与可信启动有关) . 如果输出rdmsr 0x3a
不是1或3,您将能够使用 kvm。如有必要,kvm 将设置 msr 的第 2 位,我希望 virtualbox 和其余部分具有相同的逻辑。
回答by Viswesn
Install cpu-checker and run "kvm-ok"
安装 cpu-checker 并运行“kvm-ok”
If the CPU is enabled, you should see something like:
如果启用了 CPU,您应该会看到如下内容:
INFO: /dev/kvm exists
KVM acceleration can be used
othewise
否则
INFO: /dev/kvm does not exist
HINT: sudo modprobe kvm_intel
INFO: Your CPU supports KVM extensions
INFO: KVM (vmx) is disabled by your BIOS
HINT: Enter your BIOS setup and enable Virtualization Technology (VT),
and then hard poweroff/poweron your system
KVM acceleration can NOT be used
回答by Chris Stryczynski
systool -m kvm_intel -v | grep nested
systool -m kvm_amd -v | grep nested
One of these should output:
其中之一应该输出:
nested = "1"
Which indicates it is enabled.
这表明它已启用。
回答by santhosh kumar
A simple approach to confirm that Vt-D is enabled in the BIOS is through the Linux system. If the VT-D is enable in the BIOS and Iommu=on
in the grub.cfg
then the below folder structure is created automatically to hold the Virtual devices.
确认在 BIOS 中启用 Vt-D 的简单方法是通过 Linux 系统。如果VT-d是使在BIOS和Iommu=on
在grub.cfg
接着的下面的文件夹结构是自动创建的存储虚拟设备。
/sys/kernel/iommu_groups/0/devices/0000:00:00.0
/sys/kernel/iommu_groups/0/devices/0000:00:00.0
Whereas if either one of the options VT-D or Iommu is not configured/enabled then the above mentioned folder structure is not created. This behavior is confirmed in CentOS 7.4 and Ubuntu. Hopefully this behavior is similar for other operating systems as well but this would need to be confirmed.
而如果 VT-D 或 Iommu 选项之一未配置/启用,则不会创建上述文件夹结构。此行为已在 CentOS 7.4 和 Ubuntu 中得到确认。希望这种行为也适用于其他操作系统,但这需要确认。
回答by Forivin
I found that scai's answer doesn't work on my AMD Ryzen systems.
我发现 scai 的答案在我的 AMD Ryzen 系统上不起作用。
This however works really well for me, even on Intel:
然而,这对我来说非常有效,即使在英特尔上也是如此:
if systool -m kvm_amd -v &> /dev/null || systool -m kvm_intel -v &> /dev/null ; then
echo "AMD-V / VT-X is enabled in the BIOS/UEFI."
else
echo "AMD-V / VT-X is not enabled in the BIOS/UEFI"
fi
(systool
is found in the sysfsutils
package on most distros.)
(systool
可sysfsutils
在大多数发行版的软件包中找到。)
For Intel's VT-D / AMD's IOMMU, I came up with this solution:
对于 Intel 的 VT-D / AMD 的 IOMMU,我想出了这个解决方案:
if compgen -G "/sys/kernel/iommu_groups/*/devices/*" > /dev/null; then
echo "AMD's IOMMU / Intel's VT-D is enabled in the BIOS/UEFI."
else
echo "AMD's IOMMU / Intel's VT-D is not enabled in the BIOS/UEFI"
fi
(It even worked for me if the iommu kernel parameters are not set.)
(如果未设置 iommu 内核参数,它甚至对我有用。)
回答by ghazouan badr
you can use:
您可以使用:
sudo apt-get update
sudo apt-get install cpu-checker
kvm-ok