1. Using dmidecode
Among many information listed by the dmidecode command (requires root access) one is the system-manufacturer string. If this is a physical server the command will output the vendor name, if not it will output the virtual software name.
On physical servers
# dmidecode -s system-manufacturer Dell Inc. # dmidecode -s system-manufacturer IBMOn Virtual servers
# dmidecode -s system-manufacturer VMware, Inc. # dmidecode -s system-manufacturer innotek GmbHThe innotek GmbH is from a VM server created with VirtualBox
There are other strings in the demidecode output that could also be used to find out which the server is physical or virtual.
Grep on Product on physical servers returns
# dmidecode | grep Product Product Name: PowerEdge M610 Product Name: 02Y41P Product Name: # dmidecode | grep Product Product Name: IBM System x3550 M4 Server -[7914ZT7]- Product Name: 00J6242On virtual servers return
# dmidecode | grep Product Product Name: VMware Virtual Platform Product Name: 440BX Desktop Reference Platform # dmidecode | grep Product Product Name: VirtualBox Product Name: VirtualBoxIt's also possible to grep on the string Virtual. Output from physical servers.
# dmidecode | grep Virtual VME (Virtual mode extension) # dmidecode | grep Virtual VME (Virtual mode extension) Enhanced VirtualizationOutput from virtual servers
# dmidecode | grep Virtual Product Name: VMware Virtual Platform VME (Virtual mode extension) VME (Virtual mode extension) VME (Virtual mode extension) VME (Virtual mode extension) String 2: Welcome to the Virtual Machine # dmidecode | grep Virtual Version: VirtualBox Product Name: VirtualBox Family: Virtual Machine Product Name: VirtualBox
2. Using virt-what
virt-what (included in virt-what-*.rpm, comes with RedHat and other distros) checks if the running system is a physical or virtual. This command must be run as root user.
On physical servers the command does not return anything and goes back to prompt.
[root@srv6 ~]# virt-what [root@srv6 ~]#On virtual servers
# virt-what vmware # virt-what virtualboxFor windows use SYSTEMINFO command and check System Manufacturer and System Model values. For physical machine it will actual manufacture and model details
System Manufacturer: Dell Inc. System Model: PowerEdge R210 IIFor a virtual machine it will list VM details (first one is for virtual box)
System Manufacturer: innotek GmbH System Model: VirtualBoxor
System Manufacturer: Microsoft Corporation System Model: Virtual Machine