An interesting question. I have logged into a Linux (most likely SuSE) host. Is there some way that I can tell programmatically that I am a VM host or not?
Also assume that the vmtools are not installed.
An interesting question. I have logged into a Linux (most likely SuSE) host. Is there some way that I can tell programmatically that I am a VM host or not?
Also assume that the vmtools are not installed.
Use standard Linux tools to inspect the hardware on the system.
or
or
If the output of these commands shows hardware with a manufacturer name of "VMWare", you're on a VMWare VM. Multiple commands are provided here because system configurations and tools differ.
indicates that it’s a VM. If it returned “physical” then the opposite is true (not a VM), eg:
You might be able to get and idea by looking around under
/sys
. For example/sys/class/dmi/id/sys_vendor
has a value ofVMware, Inc.
.If it is installed you can use lshw. The command
lshw -class system
returns this on my system:There is a handy app that might help called virt-what. I haven't used it with VMWare, but it did work nicely with Qemu.
Some virtual environments name some of their virtual devices with names that are a bit tell-tale, for example, VirtualBox presenting a graphics card that calls itself "VirtualBox Display Adapter". But looking for those ties you to a particular VM and possibly a narrow range of versions.
It might be possible for your code to see what sort of virtualisation it could set up. If that fails entirely, you might be in a VM. But you just as might easily be on a box that doesn't have any VM capable hardware.
There's lots of code out there to detect if you're in a VM or not. Start with red pill and search from there. This paper at Offensive Computing is also a good read.
That's if none of those easy ones above work :)
For Linux you type
dmesg |grep DMI
:VIRTUAL HOST OUTPUT
FOR PHYSICAL HOST EXAMPLE
You could also search the first part of your mac address here and see if it's listed as assigned to any of the virtualization companies.
Virtual devices will also be revealed by lspci and/or disk device info in /proc:
In Linux, system information is revealed in /sys/devices/virtual/dmi/id/ . See my answer here for a handy script to show you all the information available.
root not required.