How to determine whether a host system is a virtual or physical machine

The easiest way on how to determine whether a local or remote host is a virtual machine or bare metal physical server is to use Puppet Lab’s tool facter. First we need to install facter:

# apt-get install facter
# yum install facter

The following steps will describe an OS-agnostic facter installation using ruby command. If necessary please update the below URL with a desired facter version number:

curl -s | tar xz; ruby facter*/install.rb

Next, use facter to determine whether your host system is physical or virtual machine:

# facter 2> /dev/null | grep virtual
is_virtual => true
virtual => virtualbox

From the above output we can see that the system is a virtual machine running on VirtualBox. The following facter output will be show for a bare metal physical machine:

# facter 2> /dev/null | grep virtual    
is_virtual => false
virtual => physical