Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Is there any way to find out if the OS I'm running (actually installing) is running in a VMWare machine. I need to disable ntp settings if the automated install is done on a virtual machine but keep them enabled if installing on bare metal.

share|improve this question

10 Answers 10

Linux adds the hypervisor flag to /proc/cpuinfo if the kernel detects running on some sort of a hypervisor.

share|improve this answer
up vote 5 down vote accepted

Using dmidecode or lshw and greping seems to be to be the best way to find out.

share|improve this answer

On Linux you can use the command virt-what

[root@myhost]# virt-what
share|improve this answer

If all you need is a way to tell whether the OS/host is a virtualized host or not, just you have a perl module Sys::Detect::Virtualization and the script with it virtdetect. It does all the possible heuristics/guess detections and reports the detected OS environment. Give it a try.

share|improve this answer

You could try Joanna Rutkowska's Red Pill This little program examines the IDTR (interrupt descriptor table register) using the SIDT instruction (x86 only), which apparently will be set differently by different VMMs.

share|improve this answer

The best idea would probably to look at the hardware. At least with VirtualBox you can easily determine that you are on a virtual machine, due to the names of some of the hardware devices (for example /sys/block/sda/device/model will say "VBOX HARDDISK").

Since all your machines are VMware, just pick one of those things and check that.

share|improve this answer
that will work if i'm only using virtual harddrives. – ulve Nov 2 '10 at 7:07
The Harddisk was just an example, check for other devices, maybe the harddisk controller or the graphics card (I don't have vmware here so I cannot check) – tante Nov 2 '10 at 8:25


$ dmesg |grep -i hypervisor
Hypervisor detected: KVM
share|improve this answer

This worked better for me as it gives me specific information about the manufacturer and the product name.

dmidecode -t system|grep 'Manufacturer\|Product'

Output on Dell server:

Manufacturer: Dell Inc.
Product Name: PowerEdge C5220

Output on Virtualbox VM:

Manufacturer: innotek GmbH
Product Name: VirtualBox

Output on KVM/QEMU:

Manufacturer: QEMU
Product Name: Standard PC (i440FX + PIIX, 1996)

This is great for scripts that can parse these out for better identification of servers... but if you use Chef in your infrastructure, you can check the node attribute Virtualization -> system in the chef server .

share|improve this answer

well, the most intuitive way I always do is:

$ dmesg | grep -i vmware

share|improve this answer
nice - this works on virtual box: dmesg | grep -i vbox - ACPI: RSDP 000e0000 00024 (v02 VBOX ) – Danny Staple May 9 '13 at 14:40

I have done it:

hypervisor=`dmesg --notime | grep -i hypervisor | cut -d ':' -f2 | tr -d " \t\n\r"
echo "Hypervisor is $hypervisor"

It helps on scripts

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.