Linux can be run on various platforms including bare-metal, virtual servers, and even containers. If you are running a Linux server on a virtualized environment such as VirtualBox, you might probably want to know which type of virtualization technology it is running on.
In this guide, we explore various ways how to find the virtualization type on a Linux system.
1. Check Virtualization Type Using hostnamectl Command
The hostnamectl command is a command mostly used to display or set the system’s static hostname. On top of that, it displays other details about your Linux machine such as:
- Machine and Boot ID
- Virtualization type
- Operating system
- Hardware Vendor and Model
As such, you can easily find out the virtualization technology on which your Linux server is hosted by simply running the command without any command-line options.
From the output below, you can see that the system is running on KVM virtualization.
You can further narrow down the search results using the grep utility as follows.
$ hostnamectl | grep -i virtualization Virtualization: kvm
2. Find Virtualization Type Using systemd-detect-virt Command
Modern Linux systems ship with systemd as the init system. The systemd package provides the systemd-detect-virt utility which can be invoked on the command line to detect the virtualization technology being used.
When executed on the command line, it reports the virtualization technology your system is running on.
$ systemd-detect-virt kvm
If the system is hosted on VMWare, you will get the following output.
$ systemd-detect-virt vmware
If your Linux machine is running on Oracle VirtualBox, you will get oracle as the virtualization type printed on the terminal.
$ systemd-detect-virt oracle
To list all the detectable virtualization environments, run the command:
$ systemd-detect-virt --list
3. List Virtualization Type Using virt-what Command
The virt-what utility is basically a shell script that is used to determine if a program is running on a virtualization platform.
The shell script prints out the virtualization technology that your system is running on. If nothing is printed, it means that your machine is running on a physical or bare metal system or running on a virtualization technology that is yet to be recognized or identified.
The virt-what utility is not provided by default, and therefore, follows the steps below to install it.
$ sudo apt install virt-what [On Debian, Ubuntu and Mint] $ sudo yum install virt-what [On RHEL/CentOS/Fedora and Rocky/AlmaLinux] $ sudo emerge -a virt-what [On Gentoo Linux] $ sudo apk add virt-what [On Alpine Linux] $ sudo pacman -S virt-what [On Arch Linux] $ sudo zypper install virt-what [On OpenSUSE]
To view the virtualization type that your system is using, simply run:
$ sudo virt-what
4. Check Virtualization Type Using dmidecode Command
The dmidecode utility is a command line tool that parses the SMBIOS data, which reads both firmware and hardware data and prints it on the command line.
Apart from that, it can also display the virtualization type as follows.
$ sudo dmidecode -s system-product-name
This wraps our guide. In this tutorial, we have examined various ways of finding out the virtualization platform on which your system is running. As always, your feedback is welcome.