blog/ How to detect virtualization

Update: You may be interested in [[the perl module|perl-module-for-virtualization-detection]] implementing these tricks.

Frequently, our customers want to install our software in a virtual machine. This can be OK, but frequently they hit a CPU, memory, or IO limit caused by running in a constrained virtual environment. When this happens, we really like to know if they're running under virtualization when we try to support them. Here's some tricks to detect, from a shell, if the system is virtualized.

The first thing to check is dmesg. On a recently-booted system, checking the 'dmesg' command output may be sufficient. Otherwise, try "cat /var/log/dmesg" instead of "dmesg"

On longer-running systems, you may need to grep /var/log/dmesg instead.

If that doesn't produce anything useful, try using dmidecode to look at the BIOS information. Frequently, there will be at least one component identifying itself as virtualized:

You should just examine the output of dmidecode directly rather than trying to grep as above, in case the output changes. QEMU, for example, doesn't report the vendor in all versions.

Next, check disk devices for identification as virtualized:

If you've got tips for other virtualized environments, let me know and I'll add them to the list.