Linux test hardware virtualization

How to determine Linux guest VM virtualization technology

Determine Linux guest VM virtualization

As I said earlier, we need to use virt-what Linux command to find if the program is running in a virtual machine or not. It supports various hypervisors. Let us see how to install virt-what under differnet Linux distros.

Debian or Ubuntu Linux instllation

Run the apt command/apt-get command:
$ sudo apt-get install virt-what
OR
$ sudo apt install virt-what

Fig.01: Debian/Ubuntu Linux install virt-what command

Installing virt-what on RHEL/CentOS/Scientific Linux VM

Use the yum command:
$ sudo yum install virt-what

Fig.02: Fedora/RHEL/CentOS Linux install virt-what command

Fedora Linux VM install virt-what to detect if we are running in a virtual machine

Execute the dnf command:
$ sudo dnf install virt-what

Suse/OpenSUSE installation

Run the zypper command:
sudo zypper in virt-what

Check if your remote server runs in virtual environment

Simply type the following command:
$ $ sudo virt-what
xen
xen-domU

Another output:
$ $ sudo virt-what
kvm
Here is one more output:
$ $ sudo virt-what
lxc
This one is from AWS:
$ sudo virt-what
xen
xen-hvm
aws

Easy way to determine virtualization technology

Other possible values

  1. hyperv : This is Microsoft Hyper-V hypervisor.
  2. parallels : The guest is running inside Parallels Virtual Platform (Parallels Desktop, Parallels Server).
  3. powervm_lx86 : The guest is running inside IBM PowerVM Lx86 Linux/x86 emulator.
  4. qemu : This is QEMU hypervisor using software emulation.
  5. virtualpc : The guest appears to be running on Microsoft VirtualPC.
  6. xen-hvm : This is a Xen guest fully virtualized (HVM).
  7. uml : This is a User-Mode Linux (UML) guest.
  8. openvz : The guest appears to be running inside an OpenVZ or Virtuozzo container.
  9. linux_vserver : This process is running in a Linux VServer container.
  10. ibm_systemz : This is an IBM SystemZ (or other S/390) hardware partitioning system.

If nothing is printed, then it can mean *either* that the program is running on bare-metal *or* the program is running inside a type of virtual machine which we don’t know about or cannot detect. Here is the source code of the script:

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

systemd (I’ve read that centos7 has systemd) has the same functionality “#systemd-detect-virt “.

You have missed to comment one of the main players in the game: “VMware”. I was looking for the detection of VMware but you did not comment on it on the article. I had to read the script to realize it is detected as well.

By the way, nice post. and absolutely fantastic blog.

Thanks for the kind words. Yes, it detects vmware too.

Good write up, I typically just do: “parted /dev/sda print” and I can tell by the virtual disk name what it is.

It’s appeared on my EL5 and EL6 systems for the past few years as part of default installations. Ubuntu has it, and the source is available as well. In “recent” linux kernels, the kernel detects the hypervisor for you and prints a message that is easily available with

It might be possible for your code to see what sort of virtualisation it could set up. If that fails entirely, you might be in a VM. But you just as might easily be on a box that doesn’t have any VM capable hardware.

Источник

Linux Find Out If CPU Support Intel VT/AMD-V Virtualization For KVM

H ow do I find out if my system support Intel – VT / AMD -V hardware virtualization extensions for host CPU using the command line options? How do I check if my Linux hardware from HP/IBM/Dell supports virtualization?

Both Intel and AMD CPU support virtualization technology which allows multiple operating systems to run simultaneously on an x86 server or computer in a safe and efficient manner using hardware virtualization. XEN, KVM, Vmware and other virtualization software can use Intel and AMD hardware virtualization for full virtualization. In other words with Intel VT, or AMD-V you can run an unmodified guest OS, like MS-Windows without any problems. To run KVM, you need a CPU that supports hardware virtualization.[donotprint]

Tutorial details
Difficulty level Easy
Root privileges No
Requirements Intel/AMD x86 server
Est. reading time 2m

[/donotprint]

Say hello to /proc/cpuinfo file

The /proc/cpuinfo file has information about your CPU. The information includes, the number of CPUs, threads, cores, sockets, and Non-Uniform Memory Access (NUMA) nodes. There is also formation about the CPU caches and cache sharing, family, model, bogoMIPS, byte order, and stepping. You need to note down the following vendor specific cpu flags:

Am I using 64 bit CPU/system [x86_64/AMD64/Intel64]?

  1. lm – If you see lm flag means you’ve 64 bit Intel or AMD cpu.

Do I have hardware virtualization support?

  1. vmx – Intel VT-x, virtualization support enabled in BIOS.
  2. svm – AMD SVM,virtualization enabled in BIOS.

Do I have hardware AES/AES-NI advanced encryption support?

  1. aes – Applications performing encryption and decryption using the Advanced Encryption Standard on Intel and AMD cpus.

Commands to check if your hardware supports virtualization

Use the following commands to verify if hardware virtualization extensions is enabled or not in your BIOS.

Verify Intel VT CPU virtualization extensions on a Linux

Type the following command as root to verify that host cpu has support for Intel VT technology, enter:
# grep —color vmx /proc/cpuinfo
Sample outputs:

Fig.01: Linux check Intel VT — if my server can run full virtualization or not

Verify AMD V CPU virtualization extensions on a Linux

Type the following command as root to verify that host cpu has support for AMD – V technology:
# grep —color svm /proc/cpuinfo

Linux lscpu command to find Virtualization AMD-V support

Verify Intel or AMD 64 bit CPU

Type the following grep command:
grep -w -o lm /proc/cpuinfo | uniq
See our tutorial “Find If Processor (CPU) is 64 bit / 32 bit on a Linux” for more info.

lscpu command

The lscpu command shows CPU architecture information on a Linux server:
lscpu
Sample outputs from Intel server:

Fig.02: lscpu command on a Linux server to find out Virtualization support

Putting it all together

Type the following egrep command:

Fig.03: Finding Intel virtualization, encryption and 64 bit cpu in a single command

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

Additional Intel x86 CPU specific virtualization flags

  1. ept – Intel extended page table support enabled to make emulation of guest page tables faster.
  2. vpid – Intel virtual processor ID. Make expensive TLB flushes unnecessary when context switching between guests.
  3. tpr_shadow and flexpriority – Intel feature that reduces calls into the hypervisor when accessing the Task Priority Register, which helps when running certain types of SMP guests.
  4. vnmi – Intel Virtual NMI helps with selected interrupt events in guests.

Additional AMD x86 CPU specific virtualization flags

  1. npt – AMD Nested Page Tables, similar to Intel EPT.
  2. lbrv – AMD LBR Virtualization support.
  3. svm_lock – AMD SVM locking MSR.
  4. nrip_save – AMD SVM next_rip save.
  5. tsc_scale – AMD TSC scaling support.
  6. vmcb_clean – AMD VMCB clean bits support.
  7. flushbyasid – AMD flush-by-ASID support.
  8. decodeassists – AMD Decode Assists support.
  9. pausefilter – AMD filtered pause intercept.
  10. pfthreshold – AMD pause filter threshold.

Some tips to solve your problems.

Tip #1: See Linux kernel messages

Type the following command to see kvm support enabled or not in BIOS:
# dmesg | less
# dmesg | grep -i kvm

Tip # 2: Check your BIOS settings

By default, many system manufacturers disables an AMD or Intel hardware CPU virtualization technology in the BIOS. You need to reboot the system and turn it in the BIOS. Once turned on, run lscpu or grep command as discussed earlier to see if your virtualization support enabled:
$ lscpu
$ egrep -wo ‘vmx|ept|vpid|npt|tpr_shadow|flexpriority|vnmi|lm|aes’ /proc/cpuinfo | sort | uniq
$ egrep -o ‘(vmx|svm)’ /proc/cpuinfo | sort | uniq
Sampple outputs:

Tip # 3: XEN Kernel

By default, if you booted into XEN kernel it will not display svm or vmx flag using the grep command. To see if it is enabled or not from xen, enter:
cat /sys/hypervisor/properties/capabilities
You must see hvm flags in the output. If not reboot the box and set Virtualization in the BIOS.

References
  • The Linux kernel source/header file located at /usr/src/kernels/$(uname -r)/arch/x86/include/asm/cpufeature.h (or click here to see cpufeature.h online)
  • Man pages – proc(5)

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

How to check if your processor supports Virtualization Technology on Ubuntu

What is VT and why is it required?

The Virtualization Technology enables your processor to act as a number of independent computer systems. This enables several operating systems to be running on the same machine at the same time. Whenever you want to install virtualization applications on your Ubuntu system such as VMware Workstation, VirtualBox etc., you should first verify if your system supports virtualization and if it is enabled. Only then you can run virtual machines using a single processor.

The article explains the following methods to check if Virtual Technology is supported by your processor on a Ubuntu system:

  • lscpu command
  • cpu-checker utility
  • /proc/cpuinfo file
  • Libvirt client utility

We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system. We will be using the Ubuntu command line, the Terminal, in order to verify VT on our processor. You can open the Terminal application either through the system Dash or the Ctrl+Alt+T shortcut.

Verifying VT on your processor

Method 1: Through the lscpu command

The lscpu command is a popular method to extract information about your CPU’s architecture. This command extracts hardware information from the /pro/cpuinfo file of sysfs. This information includes the number of processors, CPU operation mode, sockets, cores, threads, model name, and virtualization information, among much more.

Simply run the following command in your Ubuntu Terminal:

Here is the output format you usually see:

Navigate to the Virtualization output; the result VT-x here ensures that virtualization is indeed enabled on your system.

Method 2: Through the cpu-checker utility

The cpu-checker utility is another way to check virtualization technology, among many other things. Since most Ubuntu systems do not have this facility by default, you can install is by running the following command as sudo:

Please note that only an authorized user can add/remove and configure software on Ubuntu.

After you have entered the password for sudo, the system might prompt you with a y/n option to verify if you want to continue installation. Please enter y and hit Enter after which cpu-checker will be installed on your system

The following command from this utility will help you in verifying if virtualization is supported by your processor or not: Advertisement

The above output indicates that VT is enabled on your system. However, if you get the following output, it means that you need to enable virtualization to use applications that work on this technology:

INFO: Your CPU does not support KVM extensions
KVM acceleration can NOT be used

Method 3: From the /proc/cpuinfo file

We can also manually extract relevant information from the /proc/cpuinfo file by using the egrep command. For example, because we want to extract virtualization related information, we can use egrep command as follows to extract information related to either svm or vmx:

In the output you will see information about one of the following, that will verify that virtualization is enabled on your system:

Svm: AVM-V support information

Vmx: Intel-VT technology support information

This is the output of the above-mentioned command on my system:

The vmx indication and it’s information in the output indicates that the virtual technology, Intel-VT, is enabled and supported by my system. If you do not find any output for this command, this emans that the /proc/cpuinfo does not contain any information about VT and it is either unavailable or disabled from your BIOS settings.

Method 4: Through the Libvirt client utility

There is a virtual host validation tool called virt-host-validate. In order to use this, you need to have the libvert-clients package installed on your system. Since most Ubuntu systems do not have this facility by default, you can install is by running the following command as sudo:

Please note that only an authorized user can add/remove and configure software on Ubuntu.

After you have entered the password for sudo, the system might prompt you with a y/n option to verify if you want to continue installation. Please enter y and hit Enter after which cpu-checker will be installed on your system

The following virt-host-validate command from this utility will help you in verifying if virtualization is supported by your processor or not, among many other things:

You can see that the “QEMU: checking for hardware virtualization” shows the result status as PASS on my system. This indicates that VT is indeed enabled on my processor. If the result status is “FAIL” in anyone’s output, that indicates that virtualization is either not supported or else not enabled.

So now you have not one, but four very simple ways to verify if your hardware supports virtualization. This is the power of Linux, with just one command you can perform a seemingly complex task.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Источник

Читайте также:  Linux mint login incorrect
Оцените статью