Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find if my OS is running on a virtualized or non-virtualized environment?

I have access to a machine to which I can ssh. How to determine if my OS is running in fully-virtualized (where VMM does binary translation), para-virtualized or non-virtualized environment? I have some idea of how to go about it (some operations like accessing a memory page/disk will take longer time in a virtualized environment) but don't know how to proceed.

like image 373
Bruce Avatar asked Jan 20 '13 18:01

Bruce


People also ask

How can I tell if Linux is virtualized?

If you want to check Linux Server is Physical or Virtual then you can use another important tool called hwinfo . You can grep the Product keyword from hwinfo command output as shown below. If it is a virtual machine then it will show under Product section.


1 Answers

It does depends on the VMM you are running on top of. If it's a Xen or Microsoft VM, I believe CPUID with EAX value of 0x40000000 will give you a non-zero value in EAX. Not sure if that works on VMWare, VirtualBox or KVM. I expect that it will work there too...

Measuring access time is unlikely to ALWAYS show you the truth, since in a non-VM system those can vary quite a lot as well, and there is no REAL reason that you'd see a huge difference in an efficient implementation. And of course, you don't know if your VM is running with a REAL hard-disk controller passed through via the PCI, or if your NFS mounted disks are connected via a REAL network card passed through to the VM, or if they are accessed through a virtual network card.

A good VMM shouldn't show you much difference as long as the application is behaving itself.

like image 173
Mats Petersson Avatar answered Nov 15 '22 08:11

Mats Petersson