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
:
Ubuntu/Debian: # apt-get install facter Fedora # 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 http://downloads.puppetlabs.com/facter/facter-2.4.4.tar.gz | 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