How To Check If A Linux System Is Physical Or Virtual Machine

Configurare noua (How To)

Situatie

How To Check If A Linux System Is Physical Or Virtual Machine

As a Linux administrator, sometimes you might be wondering whether you are working on a physical or virtual machine. Most of the time, you will be accessing and managing your servers remotely. You may not always have physical access of your servers, and you may not even actually know where the server is located. However, it is possible to check if your Linux system is physical or virtual machine using couple of Linux utilities. This guide lists all possible ways to check whether the Linux system you’re working on is a physical server or a virtual server.

Solutie

Pasi de urmat

Check If A Linux System Is Physical Or Virtual Machine

Method 1 – Using Dmidecode utility

The easiest way to find if we are working on a virtual or physical machine is using dmidecode utility. Dmidecode, DMI table decoder, is used to find your system’s hardware components, as well as other useful information such as serial numbers and BIOS revision.

Dmidecode comes pre-installed with most Linux distributions. Just in case, if it is not installed already, you can install it using your distribution’s package manager. Say for example, the following command will install dmidecode in DEB based systems such as Ubuntu, Linux Mint.

$ sudo apt-get install dmidecode

After installing Dmidecode, run the following command to find out whether your system is a physical or virtual machine:

$ sudo dmidecode -s system-manufacturer

If it is a physical system, you will get an output something like below.

Dell Inc
If it is virtual system created with Virtualbox, you will get the following output:

innotek GmbH

For those wondering,innotek is a German-based software company that develops PC virtualization software called VirtualBox.

If it is virtual system created with KVM/QEMU, the output will be:

QEMU

As you see in the above output, if it is a physical system, dmidecode will show the manufacturer’s name (i.e Dell Inc.). If it is a virtual system, then it will show the virtualization software/technology (i.e VirtualBox or QEMU).

Also, you can use this command to check if it is physical or virtual system.

$ sudo dmidecode | grep Product

Method 2 – Using Facter utility

Facter is a command line utility to collect and display a system’s information. Unlike Dmidecode, Facter doesn’t comes pre-installed by default. You may need to install it as shown below depending upon the Linux distribution you use.

In Arch Linux, Manjaro Linux:

$ sudo pacman -S facter

In Fedora:

$ sudo dnf install facter

In CentOS, RHEL:

$ sudo yum install epel-release
$ sudo yum installl facter

In openSUSE:

$ sudo zypper install facter

Once facter installed, run the following command to check if the system is physical or virtual machine:

$ facter 2> /dev/null | grep virtual

Alternatively, use the following command:

$ facter virtual

Or,

$ sudo facter virtual

If it is physical machine, the output will be:

physical

If it is virtual machine, you will see output something like below.

kvm

Tip solutie

Permanent
Etichetare:

Voteaza

(11 din 21 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?