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.
| ||||
|
feedback
|
|
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. | |||
|
feedback
|
|
There is a handy app that might help called virt-what and it can be downloaded here http://et.redhat.com/~rjones/virt-what/. I haven't used it with VMWare, but it did work nicely with Qemu. | |||||
feedback
|
|
You might be able to get and idea by looking around in /sys/. For example /sys/class/dmi/id/sys_vendor has a value of 'VMware, Inc.' If it is installed you can use lshw. The command lshw -class system on my system returns this.
| |||
feedback
|
|
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. | |||
feedback
|
|
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 :) | |||
|
feedback
|
|
Virtual devices will also be revealed by lspci and/or disk device info in /proc:
| |||
|
feedback
|
|
IF the VMwareTools package has been installed, you can do:
| |||
|
feedback
|
|
I didn't like any of these solutions, there's usually a VMware CDROM driver or memory driver installed so dmesg confirms or deny's it for me quickly. [server@user ~]$ dmesg |grep VMware hda: VMware Virtual IDE CDROM Drive, ATAPI CD/DVD-ROM drive Vendor: VMware Model: Virtual disk Rev: 1.0 Vendor: VMware Model: Virtual disk Rev: 1.0 Vendor: VMware Model: Virtual disk Rev: 1.0 Vendor: VMware Model: Virtual disk Rev: 1.0 Vendor: VMware Model: Virtual disk Rev: 1.0 Vendor: VMware Model: Virtual disk Rev: 1.0 Vendor: VMware Model: Virtual disk Rev: 1.0 VMware memory control driver initialized | |||
feedback
|