Learn how to check if the Linux server is a physical or VM or cloud server by observing ‘dmidecode’ command output fields.
Recently one of my friends came across a situation where he didn’t know logged in the server is physical server, virtual machine, or cloud server. So here in this article we will walk you through how to check if the server is a physical server or virtual machine. Since cloud servers are also VM there is a very thin line between identifying them as different. It takes some infrastructure knowledge and sense to differentiate between VM and cloud-hosted servers.
dmidecode command helps you through this process. This command helps you to identify the manufacturer of the system. Let’s look at its output :
root@kerneltalks# dmidecode -t system
# dmidecode 3.0
Scanning /dev/mem for entry point.
SMBIOS 2.4 present.
Handle 0x0100, DMI type 1, 27 bytes
System Information
Manufacturer: Xen
Product Name: HVM domU
Version: 4.2.amazon
Serial Number: ec27c3cb-8e3b-8a30-4325-3f388b0fxxxx
UUID: EC27C3CB-8E3B-8A30-4325-3F388B0Fxxxx
Wake-up Type: Power Switch
SKU Number: Not Specified
Family: Not Specified
-----output trimmed-----
This is output from the AWS cloud server. In the above output you have to observe the ‘System Information‘ section.
Manufacturer :
If you see Xen, VMware, Red Hat, etc here its a VM (virtual machine). VM host KVM also shows the same manufacturers. Anything other than these like Dell Inc, HP, etc (hardware manufacturing companies name) shows that you are on real physical hardware means its physical server.
Product Name :
This parameter also helps further to confirm it’s physical or VM. Here HVM denotes its virtual machine clearly. For a physical server you see the physical server model name here.
Version :
Its again narrowing down your search. Word amazon here denotes its a VM from Amazon (most likely AWS). So as I said if you know your infrastructure well, so must be knowing you have AWS servers or not. And hence you can be sure here that it’s AWS cloud server.
Even serial numbers can be a confirmation but you should have in-depth knowledge of hardware serial number nomenclature used by industry manufacturers. Mostly, physical hardware has much short, clean and human-readable serial number whereas VM has long serial which starts with virtual service name (eg, ec2 for AWS cloud, VMWare for VMware VM, etc.) This can be added confirmation and not the primary parameter for validation.
For more understanding lets look at output from virtual machine :
root@kerneltalks_vm1# dmidecode -t system
# dmidecode 2.12
SMBIOS 2.4 present.
Handle 0x0001, DMI type 1, 27 bytes
System Information
Manufacturer: VMware, Inc.
Product Name: VMware Virtual Platform
Version: None
Serial Number: VMware-56 4d c7 47 54 09 d6 39-xx xx xx xx xx xx xx xx
UUID: 564DC747-xxxx-D639-xxxx-xxxxxxxxxx
Wake-up Type: Power Switch
SKU Number: Not Specified
Family: Not Specified
-----output trimmed-----
In above output,
The manufacturer is VMware Inc. which denotes its a VM. Product Name VMware Virtual Platform clearly states its VM
Like the cloud server above we do not have version value here. But the above two values are sufficient to confirm its a VM. These values put up by hardware or system image manufacturer hence can be blank at times.
Finally, before signing off lets check output from physical machine as well –
root@kerneltalks_phy # dmidecode -t system
# dmidecode 2.11
SMBIOS 2.7 present.
Handle 0x0001, DMI type 1, 27 bytes
System Information
Manufacturer: Cisco Systems Inc
Product Name: UCSB-B200-M3
Version: 1
Serial Number: XXXXXXXXXX
UUID: 00000000-0000-0000-0000-000000000000
Wake-up Type: Other
SKU Number:
Family:
-----output trimmed-----
Here,
The manufacturer is Cisco System Inc (who is hardware manufacturer) confirming its server hosted on bare metal.
Product Name is a UCSB-B200-M3 which is the model name of Cisco Blade. Confirms server is Cisco Blade hardware (Physical server)
Checks submitted by readers
Few readers posted these commands on social media comments.
lscpu: One can observe hypervisor vendor determine if its virtual or physical server
# lscpu |grep -i hypervisor
Hypervisor vendor: Xen
hostnamectl: Works on a new distro like RHEL7. The virtualization field gives you an idea about if its physical or virtual.
root@kerneltalks # hostnamectl status |grep -i virtual
Virtualization: xen
dmesg: Check for words like KVM, hvm, or virtual in boot messages. Here Xen virtualization detected confirming its a virtual box.
# dmesg |grep -i virtual
[ 0.000000] Booting paravirtualized kernel on Xen HVM
[ 1.403040] systemd[1]: Detected virtualization xen.
[ 1.889088] xen_netfront: Initialising Xen virtual ethernet driver
Conclusion
System information like manufacturer, product name, version, the serial number can be used to observe and understand whether logged in the server is a physical server or VM (physically hosted or cloud).
If you have any other tricks or solid methods to confirm the server is physical or virtualized, please let us know in the comments below.
Share Your Comments & Feedback: