719016
719016

Reputation: 10431

check if VT-x is activated without having to reboot in Linux?

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?

Upvotes: 52

Views: 105925

Answers (8)

Forivin
Forivin

Reputation: 15488

I found that scai's answer doesn't work on my AMD Ryzen systems.

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.)

For Intel's VT-D / AMD's IOMMU, I came up with this solution:

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.)

Upvotes: 9

Cybercartel
Cybercartel

Reputation: 12592

In linux you can check cpuinfo:

cat /proc/cpuinfo| egrep "vmx|svm"

Upvotes: 5

nigel222
nigel222

Reputation: 8192

Coming late to this party but it may be a long-lived question/answer. On Ryzen, Fedora 36, none of the other answers completely clarify whether I need to reboot. Red Hat provides this

In short, to check AMD CPU:

$ grep -E 'svm|vmx' /proc/cpuinfo

(but I know that Ryzen is capable) Then,

# lsmod | grep kvm

To check for kvm_amd or kvm_intel. No kvm_amd module loaded, so that suggests a re-boot to check BIOS is needed. Will update later.

Upvotes: 2

ghazouan badr
ghazouan badr

Reputation: 486

you can use:

sudo apt-get update
sudo apt-get install cpu-checker
kvm-ok

Upvotes: 8

santhosh kumar
santhosh kumar

Reputation: 11

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.

/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.

Upvotes: 1

Viswesn
Viswesn

Reputation: 4880

Install cpu-checker and run "kvm-ok"

If the CPU is enabled, you should see something like:

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

Upvotes: 18

Tobu
Tobu

Reputation: 25416

You can use

sudo kvm-ok

from cpu-checker. On Intel, which has the most complicated logic, kvm-ok checks that 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 1 or 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.

Upvotes: 21

scai
scai

Reputation: 21469

You can use rdmsr from msr-tools to read register IA32_FEATURE_CONTROL (address 0x3a). The kernel module msr has to be loaded for this.

On most Linux systems:

sudo modprobe msr
sudo rdmsr 0x3a

Values 3 and 5 mean it's activated.

Upvotes: 42

Related Questions