Virtual Machines and Hypervisors
A traditional computer is a physical object. It’s a collection of different pieces of hardware that are plugged and bolted together so that you can load an operating system, install applications, launch them, and use them.
Hardware is expensive. Being restricted to one operating system per physical computer means the cost of running several operating systems soon becomes prohibitive. A better solution would be to allow a single physical computer to run a selection of operating systems at the same time, with each one thinking it’s running in its own, unique hardware.
Of course, the host computer has to be powerful enough to cope with the demands of the collection of virtual machines, but, given sufficient RAM and processing power in the host, virtual machines can run at near bare-metal speeds.
Since the release of the 2.6.20 kernel in 2007, Linux has had Kernel-based Virtual Machine support baked right in. Linux has several hypervisors available to it, such as VirtualBox, GNOME Boxes, and QEMU-KVM. They make use of the native KVM capability of Linux, building upon the native kernel functionality by adding user interfaces and functionality such as being able to take a snapshot of a virtual machine.
Virtual machines bring cost savings, efficiencies, simplified deployments, and—provisioned correctly—security benefits. They also facilitate scalability. New servers can be automatically spun up as demand for a service increases and shut down when demand drops. This makes them hugely popular both in the cloud and in on-premise infrastructure.
Perhaps you’re remotely administering a Linux server and you need to know whether it is a virtual machine or a physical box. Or you have a script that needs to know what type of platform it is executing on. Here are several ways you can detect if the computer you’re working on is physical or virtual.